Re: [csswg-drafts] [resize-observer] The initial size of ResizeObservation (#3664)

This is inconsistent with `IntersectionObserver`, which always delivers a notification just after observing, since

 1. When [observing a target Element](https://w3c.github.io/IntersectionObserver/#observe-target-element), `previousThresholdIndex` is set to -1.
 2. When [running the update intersection observations steps](https://w3c.github.io/IntersectionObserver/#update-intersection-observations-algo), `thresholdIndex` is set to a non-negative index:
    > Set *thresholdIndex* to the index of the first entry in *observer*.[`thresholds`](https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-thresholds) whose value is greater than *intersectionRatio*, or the length of *observer*.[`thresholds`](https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-thresholds) if *intersectionRatio* is greater than or equal to the last entry in *observer*.[`thresholds`](https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-thresholds).
 3. This ensures a IntersectionObserverEntry will be queued:
    > If *thresholdIndex* does not equal *previousThresholdIndex* or if *isIntersecting* does not equal *previousIsIntersecting*, [queue an IntersectionObserverEntry](https://w3c.github.io/IntersectionObserver/#queue-an-intersectionobserverentry)

Similarly, I think that [`ResizeObservation`](https://drafts.csswg.org/resize-observer/#dom-resizeobservation-resizeobservation-target-options) should initialize `[lastReportedSizes](https://drafts.csswg.org/resize-observer/#dom-resizeobservation-lastreportedsizes)` to something invalid like `[(-1,-1)]`, so that we consistently get a notification regardless of the current size.

`contain-intrinsic-size: auto` also needs something like this, it uses an internal ResizeObserver to store the [last remembered size](https://drafts.csswg.org/css-sizing-4/#last-remembered). And 0x0 is a valid size that should still be stored, so the callback should be invoked. See https://github.com/w3c/csswg-drafts/issues/7539

> I think (0,0) option is most useful, because it does not fire until Element is shown.

I don't think this justifies not reporting an observation for elements that do have a box but it just happens to be 0x0. Also note IntersectionObserver notifies about disconnected elements:

```js
new IntersectionObserver(console.log).observe(document.createElement("div"));
```

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3664#issuecomment-1205207489 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 4 August 2022 12:45:07 UTC