WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
326182
moveBefore() leaves selectors that depend on the child list stale
https://bugs.webkit.org/show_bug.cgi?id=326182
Summary
moveBefore() leaves selectors that depend on the child list stale
Anne van Kesteren
Reported
2026-10-03 00:28:23 PDT
Created
attachment 481650
[details]
test ContainerNode::moveBefore() runs no Style::ChildChangeInvalidation, for either the old parent or the new one. insertBefore(), appendChild() and removeChild() all wrap the DOM change in one. Since
315405@main
, Node::movingSteps() invalidates the moved subtree. But nothing invalidates the parents or their other children, so every selector that depends on the child list keeps its old result after a move. The attached test moves an element with moveBefore() and checks the result. With ?append it uses append() instead (and passes). This is probably also why dom/nodes/moveBefore/focus-within.html fails ":focus-within should be eventually up to date when moving to a subtree that would become inert via style". The inertness there comes from :has(button) on the new parent. moveBefore() already builds both child changes, with makeChildChangeForMoveRemoval() and makeChildChangeForMoveInsertion(), but only passes them to childrenChanged(). Running a Style::ChildChangeInvalidation around each half of the move would fix this, with one catch. ChildChange::isInsertion() returns false for ElementMovedInto, TextMovedInto and NonContentsChildMovedInto. ChildChangeInvalidation relies on it to choose before- or after-change invalidation, and for :empty. Other childrenChanged() overrides read isInsertion() too, so style needs its own answer for the move types rather than a change to isInsertion().
Bug 317287
is about doing less work for the moved subtree itself, which is a separate question. There is no WPT for this yet; one in dom/nodes/moveBefore/ along the lines of the attached test would cover it.
Attachments
test
(1.91 KB, text/html)
2026-10-03 00:28 PDT
,
Anne van Kesteren
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Luke Warlow
Comment 1
2026-10-07 07:48:29 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/76188
EWS
Comment 2
2026-10-07 17:22:24 PDT
Committed
323044@main
(6839061acafd): <
https://commits.webkit.org/323044@main
> Reviewed commits have been landed. Closing PR #76188 and removing active labels.
Radar WebKit Bug Importer
Comment 3
2026-10-07 17:23:17 PDT
<
rdar://problem/189461850
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug