W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2015

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

From: Anthony Ramine via GitHub <sysbot+gh@w3.org>
Date: Wed, 29 Jul 2015 09:12:40 +0000
To: www-dom@w3.org
Message-ID: <pull_request.opened-41101741-1438161159-sysbot+gh@w3.org>
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
Received on Wednesday, 29 July 2015 09:12:43 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:24 UTC