[dom] Pull Request: Queuing of mutation records looks inconsistent

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[dom] Pull Request: Queuing of mutation records looks inconsistent

r12a via GitHub
nox has just submitted a new pull request for
https://github.com/whatwg/dom:

== Queuing of mutation records looks inconsistent ==
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, <strong>queue a mutation
record</strong> of "childList" for node with removedNodes nodes.
<li>If node is a DocumentFragment node, <strong>remove</strong> 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.

See https://github.com/whatwg/dom/pull/60