-
Notifications
You must be signed in to change notification settings - Fork 756
Description
As far as I can tell, when the ResizeObserver repo was archived, issues were closed but not copied over 😞
This is a copy of WICG/resize-observer#55 from @atotic
It is an important issue because depending on the answer, not calling disconnect or unobserve could lead to memory leaks.
Original issue:
We need to clarify Object Lifetimes for ResizeObserver and Elements.
Current specification discusses states that:
A ResizeObserver will remain alive until both of these conditions are met:
- there are no scripting references to the observer.
- the observer is not observing any targets.
The relationship whether RO has influence on Element object lifetime is not discussed.
Clarifying this is important in following corner case:
let el = document.querySelector("#id");
let ro = new ResizeObserver();
ro.observe(el);
setTimeout( _ => {
el.remove();
el = null;
// will there be any notifications after this timeout executes.
// only remaining reference to el is inside RO.
}Current Chrome code implicitly unobserves element if there are no JS references to it. This is not captured by the specification.