-
Notifications
You must be signed in to change notification settings - Fork 516
Description
Presumably, like MutationObservers, IntersectionObservers are not deleted when they go out of javascript scope. The spec doesn't say anything about ownership of the observer, so how does it get cleaned up?
When a target element is removed from the DOM tree, unobserve() is called implicitly on its observer(s), but the spec says nothing about what happens when a root element is removed from the DOM tree. When that happens, unobserve() will be called implicitly for all targets on all observers for which it is root, but the observer object itself will remain intact.
The most straightforward solution, I think, is to tie the lifetime of the observer to the lifetime of its root, but then what do we do with observers that don't specify a root (i.e., they track intersections with the visual viewport)? In that case, there doesn't seem to be any way to delete those observers. Do we need an immolate() method?