Re: [whatwg/dom] replaceChild() has odd mutation observer behavior after #754 (#814)

_child_'s previous sibling is saved, but not _node_'s. The first mutation event results from step 13 of [replace](https://dom.spec.whatwg.org/#concept-node-replace)

> Insert _node_ into _parent_ before _referenceChild_ with the _suppress observers flag_ set.

which eventually goes to step 7.1 of [insert](https://dom.spec.whatwg.org/#concept-node-insert)

> Adopt _node_ into _parent_’s node document.

which goes to step 2 of [adopt](https://dom.spec.whatwg.org/#concept-node-adopt)

> If _node_’s parent is non-null, then remove _node_.

which fires a mutation event. At that time, _node_'s previous sibling has already been removed, so the fired mutation event does not contain a _previousSibling_.

----

The second mutation event in the array is a result of "queue a tree mutation record" in [replace](https://dom.spec.whatwg.org/#concept-node-replace) itself. That works fine.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/814#issuecomment-573200308

Received on Friday, 10 January 2020 20:51:50 UTC