IntersectionObserver should not notify targets in detached documents#65550
Merged
webkit-commit-queue merged 1 commit intoMay 25, 2026
Conversation
Collaborator
|
EWS run on previous version of this PR (hash f800c2c) Details |
f800c2c to
c84a26e
Compare
Collaborator
|
EWS run on current version of this PR (hash c84a26e) Details |
cdumez
approved these changes
May 25, 2026
https://bugs.webkit.org/show_bug.cgi?id=300729 rdar://162699098 Reviewed by Chris Dumez. HTML's "update the rendering" steps build the docs list from "all fully active Document objects" [1], so the intersection observer update step (Step 19) [1] never runs for a detached document. A target whose owning Document is not fully active therefore cannot legitimately produce an intersection. WebKit still queued an initial zero-rect, not-intersecting entry for such targets, so target-in-detached-document.html saw one notification before the target was adopted into a fully-active document where the specification expect none. Fix it by skipping such targets in updateObservations without advancing previousThresholdIndex, so a later adoptNode is treated as the first observation. This skip is gated on implicit root observers, "Update the rendering" [1] (Step 19) invoke "run the update intersection observations steps" [2] which iterates "all IntersectionObservers whose root is in the DOM tree of document … this includes implicit root observers". The explicit-root [3] case is left alone and continues to be tested by explicit-root-different-document.html. Drop the skipped target from m_targetsWaitingForFirstObservation so a permanently detached target/document can be collected (i.e., intersection-observer/no-document-leak.html). [1] https://html.spec.whatwg.org/#update-the-rendering [2] https://w3c.github.io/IntersectionObserver/#run-the-update-intersection-observations-steps [3] https://w3c.github.io/IntersectionObserver/#intersectionobserver-explicit-root-observer * LayoutTests/imported/w3c/web-platform-tests/intersection-observer/target-in-detached-document-expected.txt: Progression * Source/WebCore/page/IntersectionObserver.cpp: (WebCore::IntersectionObserver::updateObservations): Canonical link: https://commits.webkit.org/313834@main
c84a26e to
b49b5a0
Compare
Collaborator
|
Committed 313834@main (b49b5a0): https://commits.webkit.org/313834@main Reviewed commits have been landed. Closing PR #65550 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 ios
🧪 api-wpe
b49b5a0
c84a26e