Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b49b5a000685f86c8d7d16eaeda6fbc0a1d0e0c8
https://github.com/WebKit/WebKit/commit/b49b5a000685f86c8d7d16eaeda6fbc0a1d0e0c8
Author: Ahmad Saleem <[email protected]>
Date: 2026-05-25 (Mon, 25 May 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/intersection-observer/target-in-detached-document-expected.txt
M Source/WebCore/page/IntersectionObserver.cpp
Log Message:
-----------
IntersectionObserver should not notify targets in detached documents
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
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications