* Patches Intersection Observer polyfill by wrapping its body into `install` * function. * This gives us an option to control when and how the polyfill is installed. * The polyfill can only be installed on the root context.
()
| 61 | * The polyfill can only be installed on the root context. |
| 62 | */ |
| 63 | function patchIntersectionObserver() { |
| 64 | // Copies intersection-observer into a new file that has an export. |
| 65 | const patchedName = |
| 66 | 'node_modules/intersection-observer/intersection-observer.install.js'; |
| 67 | let file = fs |
| 68 | .readFileSync('node_modules/intersection-observer/intersection-observer.js') |
| 69 | .toString(); |
| 70 | |
| 71 | // Wrap the contents inside the install function. |
| 72 | file = `export function installIntersectionObserver() {\n${file}\n}\n`; |
| 73 | writeIfUpdated(patchedName, file); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Patches Resize Observer polyfill by wrapping its body into `install` |
no test coverage detected