Commit 5362b91
committed
Adopt node before removing child in replace
replace removes child (with suppressObservers set) before inserting
node. Because insert now adopts node as one of its steps, when node is
already in the tree its removal from the old location — and the mutation
record that removal queues — happened *after* child had already been
silently removed. That gave the record a stale previousSibling and made
the two records appear non-atomic.
Adopt node up front, before child is removed, so node's removal is
observed while child is still present. This restores the record ordering
and previousSibling that predates #754, which had removed replace's
explicit adoption step without accounting for this interaction. All
engines kept the pre-#754 behavior, so this aligns the standard with
reality.
The related replace all algorithm intentionally keeps adopting inside
insert: its only caller that can receive an already-present node is
replaceChildren(), which postdates #754 and folds such a node into its
single record.
Tests: dom/nodes/MutationObserver-childList.html (existing n52/n53
coverage) and web-platform-tests/wpt#61155.
Fixes #814.1 parent c7f757c commit 5362b91
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3194 | 3194 | | |
3195 | 3195 | | |
3196 | 3196 | | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
3197 | 3202 | | |
3198 | 3203 | | |
3199 | 3204 | | |
| |||
0 commit comments