Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: cff766b424518da09300512778d784438d252fde
https://github.com/WebKit/WebKit/commit/cff766b424518da09300512778d784438d252fde
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-06 (Tue, 06 Oct 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/NodeIterator-removal-during-filtering-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/NodeIterator-removal-expected.txt
M Source/WebCore/dom/NodeIterator.cpp
Log Message:
-----------
NodeIterator reference left on a detached node when removing an ancestor of
the reference with no following node in the root
https://bugs.webkit.org/show_bug.cgi?id=326465
rdar://189263890
Reviewed by Ryosuke Niwa.
This patch aligns WebKit with Gecko / Firefox.
When the pointer is before the reference and an inclusive ancestor of the
reference is removed, updateForNodeRemoval() walked forward with
NodeTraversal::next(), which descends into the removed subtree first. If the
removed node had children but no following node within the root, the
skip-descendants loop ran off the end to null. The else-branch fallback was
never reached, so the reference stayed on a node that had just been detached.
Rewrite the function to follow the DOM spec's "adjust a node pointer" steps
directly. Find the next node with NodeTraversal::nextSkippingChildren(), and
if there is none, fall back to (NodeTraversal::previous(removedNode), false).
previous() of the removed node can never be inside the removed subtree, so the
old descendant-skipping loops in the fallback paths were dead code and are
removed.
*
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/NodeIterator-removal-during-filtering-expected.txt:
Progression
*
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/NodeIterator-removal-expected.txt:
Ditto
* Source/WebCore/dom/NodeIterator.cpp:
(WebCore::NodeIterator::updateForNodeRemoval const):
Canonical link: https://commits.webkit.org/322933@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications