w3c/IntersectionObserver

When an Element is observed, ensure that it's document runs the "update the rendering" steps at the next rendering opportunity.

szager-chromium opened this issue · 0 comments

The expectation of developers is that when observer.observe(target) is called, an initial notification will be generated during the next rendering update (step 11 in the Document Processing Model). However, step 11.4 in the processing model allows an implementation to skip processing for a document under certain circumstances:

Unnecessary rendering: Remove from docs all Document objects which meet both of the following conditions:

  • The user agent believes that updating the rendering of the Document's browsing context would have no visible effect, and
  • The Document's map of animation frame callbacks is empty.

So it's possible that an initial IntersectionObserver notification will not be generated at the next rendering opportunity. This issue was first discussed in previous issue, and it was agreed that creating an initial notification at the first opportunity was a good idea. The spec change associated with that bug did not, however, anticipate or account for the "unnecessary rendering" mechanism described above.

The spec should be amended to include an additional, mandatory condition for skipping processing for a document; something like:

There is no IntersectionObserver whose root is in the DOM tree of the Document, which is observing a target Element for which no notification has been generated since the time observe() was called.

The actual language should probably refer to the IntersectionObserver's ObservationTargets slot, the target Element's Registered IntersectionObservers slot, and the previousThresholdIndex property on IntersectionObserverRegistration. It will probably be kinda gross, so the full details should probably be in the IntersectionObserver spec, linked from the "unnecessary rendering" section of the processing model spec.