Skip to content Skip to sidebar Skip to footer

Should An IntersectionObserver Be Disconnected When Element Is Removed

In a Single Page Application, elements are often removed and replaced. On elements that are removed from the DOM there could be an IntersectionObserver(or any other kind) For event

Solution 1:

I can't find an official post yet, but I'm going to assume it's the same as MutationObservers, which is that garbage collection is supposed to handle the removing once the DOM element is removed. See https://dom.spec.whatwg.org/#garbage-collection

I also posted the answer for MOs here: Should MutationObservers be removed/disconnected when the attached DOM node is removed like removeEventListener for events?


Post a Comment for "Should An IntersectionObserver Be Disconnected When Element Is Removed"