w3c/IntersectionObserver

Suggest using weak references

jakearchibald opened this issue · 1 comments

Mutation observers suggest that they have a weak reference to observed elements, so if the element is otherwise garbage collected, then the observer is also collected. This seems to work in practice.

However, with similar code, IntersectionObserver leaks memory. The same happens with ResizeObserver.

https://bugs.chromium.org/p/chromium/issues/detail?id=1220041 (includes demos) - the same issue effects Firefox and Safari.

The IntersectionObserver spec should suggest that observed elements are weakly referenced, similar to MutationObserver.