-
Notifications
You must be signed in to change notification settings - Fork 515
Description
I made a simple demo that modifies the polyfill so that even browsers with native support use the polyfill code instead of the native one and that showcases that the polyfill leaks memory. You can see this in action here: https://jsbin.com/fajahenoca/edit?html,js,output
Additionally I created a proof of concept, that shows a way to add an IO polyfill, that does not leak memory.
A demo of this can be found here: https://jsbin.com/necilumuze/edit?html,js,output.
And a diff can be seen here:
aFarkas/IntersectionObserver@gh-pages...memory-leaks-poc
The trick I'm using here, is to not create strong reference by adding the elements to an array, but to add a marker attribute to the elements, that need to be observed. This way the observer can search for those marked elements in the document.
It's obvious that this technique is not so clean, but it's the only way I can think of to not produce memory leaks.
In my eyes having a not leaking IO polyfill is key to use it in production.