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

Use a queue of deferred steps in the node insertion algorithm #732

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2389,16 +2389,13 @@ of a <var>node</var> into a <var>parent</var> before a <var>child</var>, run the

<p><a lt="Other applicable specifications">Specifications</a> may define
<dfn export id=concept-node-insert-ext>insertion steps</dfn> for all or some <a for=/>nodes</a>. The
algorithm is passed <var ignore>insertedNode</var>, as indicated in the <a for=/>insert</a>
algorithm below.
<!-- See https://github.com/whatwg/dom/issues/34#issuecomment-125571750 for why we might need to
adjust this further based on the requirements of the script element. There might be other ways
to define that though as Olli suggests, so leaving that out for now. -->
algorithm is passed <var ignore>insertedNode</var> and <var ignore>deferredStepsQueue</var>, as
indicated in the <a for=/>insert</a> algorithm below.

<p><a lt="other applicable specifications">Specifications</a> may define
<dfn export id=concept-node-children-changed-ext>children changed steps</dfn> for all or some
<a for=/>nodes</a>. The algorithm is passed no argument and is called from <a for=/>insert</a>,
<a for=/>remove</a>, and <a for=/>replace data</a>.
<a for=/>nodes</a>. The algorithm is passed <var ignore>deferredStepsQueue</var> and is called from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing whatwg/html#4354 (comment) by @tkent-google in a way that aligns with Chrome would also require passing "insert"/"change"/"remove" as an argument here and acting on it accordingly. (Script would ignore anything but "insert".)

Probably would have to double check whether setting textContent counts as "change" or "insert".

<a for=/>insert</a>, <a for=/>remove</a>, and <a for=/>replace data</a>.

<p>To <dfn export id=concept-node-insert>insert</dfn> a <var>node</var> into a <var>parent</var>
before a <var>child</var>, with an optional <i>suppress observers flag</i>, run these steps:
Expand Down Expand Up @@ -2437,8 +2434,10 @@ before a <var>child</var>, with an optional <i>suppress observers flag</i>, run
<li><p>Let <var>previousSibling</var> be <var>child</var>'s <a>previous sibling</a> or
<var>parent</var>'s <a>last child</a> if <var>child</var> is null.

<li><p>Let <var>deferredStepsQueue</var> be an empty <a>queue</a>.

<li>
<p>For each <var>node</var> in <var>nodes</var>, in <a>tree order</a>:
<p><a for=list>For each</a> <var>node</var> in <var>nodes</var>:

<ol>
<li><p>If <var>child</var> is null, then <a for=set>append</a> <var>node</var> to
Expand All @@ -2461,7 +2460,8 @@ before a <var>child</var>, with an optional <i>suppress observers flag</i>, run
<var>node</var>, in <a>shadow-including tree order</a>:

<ol>
<li><p>Run the <a>insertion steps</a> with <var>inclusiveDescendant</var>.
<li><p>Run the <a>insertion steps</a> with <var>inclusiveDescendant</var> and
<var>deferredStepsQueue</var>.

<li>
<p>If <var>inclusiveDescendant</var> is <a>connected</a>, then:
Expand All @@ -2487,7 +2487,11 @@ before a <var>child</var>, with an optional <i>suppress observers flag</i>, run
<li><p>If <i>suppress observers flag</i> is unset, then <a>queue a tree mutation record</a> for
<var>parent</var> with <var>nodes</var>, « », <var>previousSibling</var>, and <var>child</var>.

<li><p>Run the <a>children changed steps</a> for <var>parent</var>.
<li><p>Run the <a>children changed steps</a> for <var>parent</var> with
<var>deferredStepsQueue</var>.

<li><p>While <var>deferredStepsQueue</var> <a for=list>is not empty</a>, run the result of
<a>dequeueing</a> <var>deferredStepsQueue</var>.
</ol>


Expand Down