Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queuing of mutation records looks inconsistent #60

Closed
wants to merge 1 commit into from

Conversation

nox
Copy link
Member

@nox nox commented Jul 29, 2015

To replace a child with node within a parent, the mutation record is queued after the removal of child and insertion of node:

  1. Remove child from its parent with the suppress observers flag set.
  2. Let nodes be node’s children if node is a DocumentFragment node, and a list containing solely node otherwise.
  3. Insert node into parent before reference child with the suppress observers flag set.
  4. Queue a mutation record of "childList" for target parent with addedNodes nodes, removedNodes a list solely containing child, nextSibling reference child, and previousSibling previousSibling.

That behaviour is the same to replace all a node within a parent:

  1. Remove all parent’s children, in tree order, with the suppress observers flag set.
  2. If node is not null, insert node into parent before null with the suppress observers flag set.
  3. Queue a mutation record of "childList" for parent with addedNodes addedNodes and removedNodes removedNodes.

But for example, to insert a node into a parent before a child, mutation records are queued before the actual mutations:

  1. If node is a DocumentFragment node, queue a mutation record of "childList" for node with removedNodes nodes.
  2. If node is a DocumentFragment node, remove its children with the suppress observers flag set.

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.

@annevk
Copy link
Member

annevk commented Jul 28, 2015

You were going to PR this, correct?

nox added a commit to nox/dom that referenced this pull request Jul 29, 2015
@annevk
Copy link
Member

annevk commented Jul 29, 2015

Thank you for your PR. I ended up removing a redundant newline before committing and did not want to bother you with that. Hence the distinct commit.

annevk added a commit that referenced this pull request Oct 15, 2015
In particular, require that the root’s node document hasn’t changed.
@nox nox deleted the mutation-record-order branch December 15, 2015 10:55
hmin pushed a commit to hmin/dom that referenced this pull request Feb 17, 2017
Queuing of mutation records looks inconsistent. To replace a child with
node within a parent, the mutation record should be queued after the
removal of child and insertion of node.

See whatwg#60 for more details.
yongsheng pushed a commit to w3c/dom that referenced this pull request Feb 20, 2017
Queuing of mutation records looks inconsistent. To replace a child with
node within a parent, the mutation record should be queued after the
removal of child and insertion of node.

See whatwg#60 for more details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants