[dom] Queuing of mutation records looks inconsistent (#60)

To [replace](https://dom.spec.whatwg.org/#concept-node-replace) a *child* with *node* within a parent, the mutation record is queued after the removal of *child* and insertion of *node*:
<ol start=11>
<li><strong>Remove</strong> child from its parent with the suppress observers flag set.
<li>Let nodes be node’s children if node is a DocumentFragment node, and a list containing solely node otherwise.
<li><strong>Insert</strong> node into parent before reference child with the suppress observers flag set.
<li><strong>Queue a mutation record</strong> of "childList" for target parent with addedNodes nodes, removedNodes a list solely containing child, nextSibling reference child, and previousSibling previousSibling.
</ol>

That behaviour is the same to [replace all](https://dom.spec.whatwg.org/#concept-node-replace-all) a node within a parent:
<ol start=4>
<li><strong>Remove</strong> all parent’s children, in tree order, with the suppress observers flag set.
<li>If node is not null, <strong>insert</strong> node into parent before null with the suppress observers flag set.
<li><strong>Queue a mutation record</strong> of "childList" for parent with addedNodes addedNodes and removedNodes removedNodes.
</ol>

But for example, to [insert]((https://dom.spec.whatwg.org/#concept-node-replace-all) a node into a parent before a child, mutation records are queued before the actual mutations:
<ol start=4>
<li>If node is a DocumentFragment node, queue a mutation record of "childList" for node with removedNodes nodes.
<li>If node is a DocumentFragment node, remove its children with the suppress observers flag set.
</ol>

Shouldn't all mutation records be queued after the tree was mutated? I understand that because micro tasks are used it doesn't matter much, but the ordering inconsistency makes it look like it actually matters.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/60

Received on Saturday, 25 July 2015 14:57:39 UTC