[csswg-drafts] [resize-observer] Notification after element is no longer referenced (#5155)

jods4 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [resize-observer] Notification after element is no longer referenced ==
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:
```js
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.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5155 using your GitHub account

Received on Wednesday, 3 June 2020 08:30:37 UTC