Skip to content

Commit

Permalink
Only pass oldParent to removing steps for the node actually removed
Browse files Browse the repository at this point in the history
This more accurately represents what browsers actually implement. And
for custom elements we decided we did not need oldParent at all. So
hereby restricting the "insertion steps" and "removing steps" to
avoid accidentally depending on them doing more.
  • Loading branch information
annevk committed Mar 15, 2016
1 parent 2d5aaed commit baf4e6e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
47 changes: 25 additions & 22 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ No Editor: true
Logo: https://resources.whatwg.org/logo-dom.svg
Abstract: DOM defines a platform-neutral model for events and node trees.
Ignored Terms: EmptyString, Array, Document
Ignored Vars: p, documentFragment, ev, oldParent, em, processingInstruction, obj, tree, removedNode, C, *, intersects, collapsed
Ignored Vars: p, documentFragment, ev, oldParent, em, processingInstruction, obj, tree, insertedNode, removedNode, C, *, intersects, collapsed
Boilerplate: omit conformance, omit feedback-header
</pre>

Expand Down Expand Up @@ -1535,14 +1535,12 @@ To <dfn export for=Node id=concept-node-pre-insert>pre-insert</dfn> a

<p><a lt="Other applicable specifications">Specifications</a> may define
<dfn export for=Node id=concept-node-insert-ext>insertion steps</dfn> for all or some <a>nodes</a>.
The algorithm is passed <var>insertedNode</var> and <var>newAncestor</var> as indicated in the
<a for=Node>insert</a> algorithm below.
The algorithm is passed <var>insertedNode</var>, as indicated in the <a for=Node>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. -->

<p class="note"><var>newAncestor</var> can be <var>insertedNode</var>'s <a>parent</a>.

To <dfn export id=concept-node-insert for=Node>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 @@ -1600,9 +1598,9 @@ into a <var>parent</var> before a <var>child</var>, with an optional
<li><p>Insert <var>node</var> into <var>parent</var> before <var>child</var> or at the end of
<var>parent</var> if <var>child</var> is null.

<li><p>For each <a>shadow-root-including inclusive descendant</a> <var>descendant</var> of
<var>node</var>, in <a>shadow-root-including tree order</a>, run the <a>insertion steps</a> with
<var>descendant</var> and <var>parent</var>.
<li><p>For each <a>shadow-root-including inclusive descendant</a> <var>inclusiveDescendant</var>
of <var>node</var>, in <a>shadow-root-including tree order</a>, run the <a>insertion steps</a>
with <var>inclusiveDescendant</var>.
</ol>

<li>If <i>suppress observers flag</i> is unset,
Expand Down Expand Up @@ -1798,10 +1796,8 @@ To <dfn export for=Node id=concept-node-pre-remove>pre-remove</dfn> a

<p><a lt="Other applicable specifications">Specifications</a> may define
<dfn export for=Node id=concept-node-remove-ext>removing steps</dfn> for all or some <a>nodes</a>.
The algorithm is passed <var>removedNode</var> and <var>oldAncestor</var>, as indicated in the
<a>remove</a> algorithm below.

<p class="note"><var>oldAncestor</var> can be <var>removedNode</var>'s former <a>parent</a>.
The algorithm is passed <var>removedNode</var>, and optionally <var>oldParent</var>, as indicated in
the <a>remove</a> algorithm below.

To <dfn export for=Node id=concept-node-remove>remove</dfn> a <var>node</var>
from a <var>parent</var>, with an optional <i>suppress observers flag</i>, run these
Expand Down Expand Up @@ -1850,9 +1846,11 @@ steps:

<li>Remove <var>node</var> from its <var>parent</var>.

<li><p>For each <a>shadow-root-including inclusive descendant</a> <var>descendant</var> of
<var>node</var>, in <a>shadow-root-including tree order</a>, run the <a>removing steps</a> with
<var>descendant</var> and <var>parent</var>.
<li><p>Run the <a>removing steps</a> with <var>node</var> and <var>parent</var>.

<li><p>For each <a>shadow-root-including descendant</a> <var>descendant</var> of <var>node</var>,
in <a>shadow-root-including tree order</a>, run the <a>removing steps</a> with
<var>descendant</var>.

<li>For each <a>inclusive ancestor</a> <var>inclusiveAncestor</var> of
<var>parent</var>, if <var>inclusiveAncestor</var> has any <a>registered observers</a>
Expand Down Expand Up @@ -5004,17 +5002,22 @@ interface ShadowRoot : DocumentFragment {
<dfn export id=concept-shadow-root-including-tree-order>shadow-root-including tree order</dfn>, is
<a>shadow-root-including preorder, depth-first traversal</a> of a <a>tree</a>.
<dfn noexport>shadow-root-including preorder, depth-first traversal</dfn> of a <a>tree</a>
<var>tree</var> is preorder, depth-first traversal of <var>tree</var>, with for each <a>element</a>
<var>element</var> encountered in <var>tree</var>, whose <a for=Element>shadow root</a> is non-null,
<a>shadow-root-including preorder, depth-first traversal</a> of the <a>element</a>'s
<var>tree</var> is preorder, depth-first traversal of <var>tree</var>, with for each
<a for=/>element</a> <var>element</var> encountered in <var>tree</var>, whose
<a for=Element>shadow root</a> is non-null,
<a>shadow-root-including preorder, depth-first traversal</a> of the <a for=/>element</a>'s
<a for=Element>shadow root</a>'s <a>tree</a> just after it is encountered.

<p>An object <var>A</var> is a
<dfn export id=concept-shadow-root-including-descendant>shadow-root-including descendant</dfn> of an
object <var>B</var>, if <var>A</var> is a <a>descendant</a> of <var>B</var>, or <var>A</var>'s
<a for=tree>root</a> is a <a for=/>shadow root</a> and <var>A</var>'s <a for=tree>root</a>'s
<a for=DocumentFragment>host</a> is a <a>shadow-root-including inclusive descendant</a> of
<var>B</var>.

<p>A
<dfn export id=concept-shadow-root-including-inclusive-descendant>shadow-root-including inclusive descendant</dfn>
of an object <var>B</var>, if <var>A</var> is an <a>inclusive descendant</a> of <var>B</var>, or
<var>A</var>'s <a for=tree>root</a> is a <a for=/>shadow root</a> and <var>A</var>'s
<a for=tree>root</a>'s <a for=DocumentFragment>host</a> is a
<a>shadow-root-including inclusive descendant</a> of <var>B</var>.
is an object or one of its <a>shadow-root-including descendants</a>.

<hr>

Expand Down
23 changes: 15 additions & 8 deletions dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,8 @@ <h4 class="heading settled" data-level="4.2.1" id="mutation-algorithms"><span cl
<li>Return <var>node</var>.
</ol>
<p><a data-link-type="dfn" href="#other-applicable-specifications">Specifications</a> may define <dfn data-dfn-for="Node" data-dfn-type="dfn" data-export="" id="concept-node-insert-ext">insertion steps<a class="self-link" href="#concept-node-insert-ext"></a></dfn> for all or some <a data-link-type="dfn" href="#concept-node">nodes</a>.
The algorithm is passed <var>insertedNode</var> and <var>newAncestor</var> as indicated in the <a data-link-type="dfn" href="#concept-node-insert">insert</a> algorithm below. </p>
<p class="note" role="note"><var>newAncestor</var> can be <var>insertedNode</var>’s <a data-link-type="dfn" href="#concept-tree-parent">parent</a>. </p>
The algorithm is passed <var>insertedNode</var>, and optionally <var>newParent</var>, as indicated
in the <a data-link-type="dfn" href="#concept-node-insert">insert</a> algorithm below. </p>
<p>To <dfn data-dfn-for="Node" data-dfn-type="dfn" data-export="" id="concept-node-insert">insert<a class="self-link" href="#concept-node-insert"></a></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:</p>
<ol>
<li>Let <var>count</var> be the number of <a data-link-type="dfn" href="#concept-tree-child">children</a> of <var>node</var> if
Expand All @@ -1077,7 +1077,10 @@ <h4 class="heading settled" data-level="4.2.1" id="mutation-algorithms"><span cl
<li>
<p>Insert <var>node</var> into <var>parent</var> before <var>child</var> or at the end of <var>parent</var> if <var>child</var> is null. </p>
<li>
<p>For each <a data-link-type="dfn" href="#concept-shadow-root-including-inclusive-descendant">shadow-root-including inclusive descendant</a> <var>descendant</var> of <var>node</var>, in <a data-link-type="dfn" href="#concept-shadow-root-including-tree-order">shadow-root-including tree order</a>, run the <a data-link-type="dfn" href="#concept-node-insert-ext">insertion steps</a> with <var>descendant</var> and <var>parent</var>. </p>
<p>Run the <a data-link-type="dfn" href="#concept-node-insert-ext">insertion steps</a> with <var>node</var> and <var>parent</var>. </p>
<li>
<p>For each <a data-link-type="dfn" href="#concept-shadow-root-including-descendant">shadow-root-including descendant</a> <var>descendant</var> of <var>node</var>,
in <a data-link-type="dfn" href="#concept-shadow-root-including-tree-order">shadow-root-including tree order</a>, run the <a data-link-type="dfn" href="#concept-node-insert-ext">insertion steps</a> with <var>descendant</var>. </p>
</ol>
<li>If <i>suppress observers flag</i> is unset, <a data-link-type="dfn" href="#queue-a-mutation-record">queue a mutation record</a> of "<code>childList</code>" for <var>parent</var> with addedNodes <var>nodes</var>, nextSibling <var>child</var>, and previousSibling <var>child</var>’s <a data-link-type="dfn" href="#concept-tree-previous-sibling">previous sibling</a> or <var>parent</var>’s <a data-link-type="dfn" href="#concept-tree-last-child">last child</a> if <var>child</var> is null.
</ol>
Expand Down Expand Up @@ -1147,8 +1150,8 @@ <h4 class="heading settled" data-level="4.2.1" id="mutation-algorithms"><span cl
<li>Return <var>child</var>.
</ol>
<p><a data-link-type="dfn" href="#other-applicable-specifications">Specifications</a> may define <dfn data-dfn-for="Node" data-dfn-type="dfn" data-export="" id="concept-node-remove-ext">removing steps<a class="self-link" href="#concept-node-remove-ext"></a></dfn> for all or some <a data-link-type="dfn" href="#concept-node">nodes</a>.
The algorithm is passed <var>removedNode</var> and <var>oldAncestor</var>, as indicated in the <a data-link-type="dfn" href="#concept-node-remove">remove</a> algorithm below. </p>
<p class="note" role="note"><var>oldAncestor</var> can be <var>removedNode</var>’s former <a data-link-type="dfn" href="#concept-tree-parent">parent</a>. </p>
The algorithm is passed <var>removedNode</var>, and optionally <var>oldParent</var>, as indicated in
the <a data-link-type="dfn" href="#concept-node-remove">remove</a> algorithm below. </p>
<p>To <dfn data-dfn-for="Node" data-dfn-type="dfn" data-export="" id="concept-node-remove">remove<a class="self-link" href="#concept-node-remove"></a></dfn> a <var>node</var> from a <var>parent</var>, with an optional <i>suppress observers flag</i>, run these
steps:</p>
<ol>
Expand All @@ -1165,7 +1168,10 @@ <h4 class="heading settled" data-level="4.2.1" id="mutation-algorithms"><span cl
<li>Let <var>oldNextSibling</var> be <var>node</var>’s <a data-link-type="dfn" href="#concept-tree-next-sibling">next sibling</a>.
<li>Remove <var>node</var> from its <var>parent</var>.
<li>
<p>For each <a data-link-type="dfn" href="#concept-shadow-root-including-inclusive-descendant">shadow-root-including inclusive descendant</a> <var>descendant</var> of <var>node</var>, in <a data-link-type="dfn" href="#concept-shadow-root-including-tree-order">shadow-root-including tree order</a>, run the <a data-link-type="dfn" href="#concept-node-remove-ext">removing steps</a> with <var>descendant</var> and <var>parent</var>. </p>
<p>Run the <a data-link-type="dfn" href="#concept-node-remove-ext">removing steps</a> with <var>node</var> and <var>parent</var>. </p>
<li>
<p>For each <a data-link-type="dfn" href="#concept-shadow-root-including-descendant">shadow-root-including descendant</a> <var>descendant</var> of <var>node</var>,
in <a data-link-type="dfn" href="#concept-shadow-root-including-tree-order">shadow-root-including tree order</a>, run the <a data-link-type="dfn" href="#concept-node-remove-ext">removing steps</a> with <var>descendant</var>. </p>
<li>For each <a data-link-type="dfn" href="#concept-tree-inclusive-ancestor">inclusive ancestor</a> <var>inclusiveAncestor</var> of <var>parent</var>, if <var>inclusiveAncestor</var> has any <a data-link-type="dfn" href="#registered-observer">registered observers</a> whose <b>options</b>' <code class="idl"><a data-link-type="idl" href="#dom-mutationobserverinit-subtree">subtree</a></code> is true, then for each
such <a data-link-type="dfn" href="#registered-observer">registered observer</a> <var>registered</var>, append a <a data-link-type="dfn" href="#transient-registered-observer">transient registered observer</a> whose <b>observer</b> and <b>options</b> are identical to those of <var>registered</var> and <b>source</b> which is <var>registered</var> to <var>node</var>’s list of <a data-link-type="dfn" href="#registered-observer">registered observers</a>.
<li>If <i>suppress observers flag</i> is unset, <a data-link-type="dfn" href="#queue-a-mutation-record">queue a mutation record</a> of "<code>childList</code>" for <var>parent</var> with removedNodes a list solely containing <var>node</var>,
Expand Down Expand Up @@ -2779,7 +2785,8 @@ <h3 class="heading settled" data-level="4.8" id="interface-shadowroot"><span cla
<p>The <dfn class="idl-code" data-dfn-for="ShadowRoot" data-dfn-type="attribute" data-export="" id="dom-shadowroot-host"><code>host</code><a class="self-link" href="#dom-shadowroot-host"></a></dfn> attribute’s getter must return the <a data-link-type="dfn" href="#context-object">context object</a>’s <a data-link-type="dfn" href="#concept-documentfragment-host">host</a>. </p>
<hr>
<p>In <dfn data-dfn-type="dfn" data-export="" id="concept-shadow-root-including-tree-order">shadow-root-including tree order<a class="self-link" href="#concept-shadow-root-including-tree-order"></a></dfn>, is <a data-link-type="dfn" href="#shadow-root-including-preorder-depth-first-traversal">shadow-root-including preorder, depth-first traversal</a> of a <a data-link-type="dfn" href="#concept-tree">tree</a>. <dfn data-dfn-type="dfn" data-noexport="" id="shadow-root-including-preorder-depth-first-traversal">shadow-root-including preorder, depth-first traversal<a class="self-link" href="#shadow-root-including-preorder-depth-first-traversal"></a></dfn> of a <a data-link-type="dfn" href="#concept-tree">tree</a> <var>tree</var> is preorder, depth-first traversal of <var>tree</var>, with for each <a data-link-type="dfn" href="#concept-element">element</a> <var>element</var> encountered in <var>tree</var>, whose <a data-link-type="dfn" href="#concept-element-shadow-root">shadow root</a> is non-null, <a data-link-type="dfn" href="#shadow-root-including-preorder-depth-first-traversal">shadow-root-including preorder, depth-first traversal</a> of the <a data-link-type="dfn" href="#concept-element">element</a>’s <a data-link-type="dfn" href="#concept-element-shadow-root">shadow root</a>’s <a data-link-type="dfn" href="#concept-tree">tree</a> just after it is encountered. </p>
<p>An object <var>A</var> is a <dfn data-dfn-type="dfn" data-export="" id="concept-shadow-root-including-inclusive-descendant">shadow-root-including inclusive descendant<a class="self-link" href="#concept-shadow-root-including-inclusive-descendant"></a></dfn> of an object <var>B</var>, if <var>A</var> is an <a data-link-type="dfn" href="#concept-tree-inclusive-descendant">inclusive descendant</a> of <var>B</var>, or <var>A</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a> is a <a data-link-type="dfn" href="#concept-shadow-root">shadow root</a> and <var>A</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a>’s <a data-link-type="dfn" href="#concept-documentfragment-host">host</a> is a <a data-link-type="dfn" href="#concept-shadow-root-including-inclusive-descendant">shadow-root-including inclusive descendant</a> of <var>B</var>. </p>
<p>An object <var>A</var> is a <dfn data-dfn-type="dfn" data-export="" id="concept-shadow-root-including-descendant">shadow-root-including descendant<a class="self-link" href="#concept-shadow-root-including-descendant"></a></dfn> of an
object <var>B</var>, if <var>A</var> is a <a data-link-type="dfn" href="#concept-tree-descendant">descendant</a> of <var>B</var>, or <var>A</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a> is a <a data-link-type="dfn" href="#concept-shadow-root">shadow root</a> and <var>A</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a>’s <a data-link-type="dfn" href="#concept-documentfragment-host">host</a> is <var>B</var> or a <a data-link-type="dfn" href="#concept-shadow-root-including-descendant">shadow-root-including descendant</a> of <var>B</var>. </p>
<hr>
<p class="XXX">For now you can find more information about this object in <a href="https://w3c.github.io/webcomponents/spec/shadow/">Shadow DOM</a>. The DOM Standard will be
updated over time to cover more details. </p>
Expand Down Expand Up @@ -5463,7 +5470,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
<li><a href="#concept-element-shadow-root">dfn for Element</a><span>, in §4.9</span>
</ul>
<li><a href="#dom-element-shadowroot">shadowRoot</a><span>, in §4.9</span>
<li><a href="#concept-shadow-root-including-inclusive-descendant">shadow-root-including inclusive descendant</a><span>, in §4.8</span>
<li><a href="#concept-shadow-root-including-descendant">shadow-root-including descendant</a><span>, in §4.8</span>
<li><a href="#shadow-root-including-preorder-depth-first-traversal">shadow-root-including preorder, depth-first traversal</a><span>, in §4.8</span>
<li><a href="#concept-shadow-root-including-tree-order">shadow-root-including tree order</a><span>, in §4.8</span>
<li><a href="#dictdef-shadowrootinit">ShadowRootInit</a><span>, in §4.9</span>
Expand Down

0 comments on commit baf4e6e

Please sign in to comment.