Skip to content

Commit

Permalink
Make adoption account for DocumentFragment nodes with hosts
Browse files Browse the repository at this point in the history
Tests: ...

Corresponding HTML PR: ...

Closes #813 and closes #814.
  • Loading branch information
annevk committed Nov 6, 2020
1 parent 0e4ee38 commit 9a1e814
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -5273,10 +5273,15 @@ when invoked, must run these steps:
algorithm is passed <var>node</var> and <var>oldDocument</var>, as indicated in the <a>adopt</a>
algorithm.

<p>To <dfn export id=concept-node-adopt>adopt</dfn> a <var>node</var> into a <var>document</var>, run
these steps:
<p>To <dfn export id=concept-node-adopt>adopt</dfn> a <var>node</var> into a <var>document</var>,
with an optional <var>forceDocumentFragmentAdoption</var>, run these steps:

<ol>
<li>
<p>If <var>forceDocumentFragmentAdoption</var> is not given, then set it false.

<p class=note>This is needed for HTML's <{template}> element.

<li><p>Let <var>oldDocument</var> be <var>node</var>'s <a for=Node>node document</a>.

<li><p>If <var>node</var>'s <a for=tree>parent</a> is non-null, then <a for=/>remove</a>
Expand All @@ -5291,6 +5296,15 @@ these steps:
<a>shadow-including inclusive descendants</a>:

<ol>
<li>
<p>If <var>forceDocumentFragmentAdoption</var> is false, <var>inclusiveDescendant</var> is a
{{DocumentFragment}} <a for=/>node</a>, <var>inclusiveDescendant</var> is <var>node</var>, and
<var>node</var>'s <a for=DocumentFragment>host</a> is non-null, then
<a for=iteration>continue</a>.

<p class=note>This is only reasonable as long as all <a>adopt</a> callers remove the children
of <var>node</var>.

<li><p>Set <var>inclusiveDescendant</var>'s <a for=Node>node document</a> to <var>document</var>.

<li><p>If <var>inclusiveDescendant</var> is an <a for=/>element</a>, then set the
Expand Down Expand Up @@ -5320,6 +5334,12 @@ must run these steps:
<li><p>If <var>node</var> is a <a for=/>shadow root</a>, then <a>throw</a> a
"{{HierarchyRequestError!!exception}}" {{DOMException}}.

<li>
<p>If <var>node</var> is a {{DocumentFragment}} <a for=/>node</a> and its
<a for=DocumentFragment>host</a> is non-null, then return <var>node</var>.

<p class=note>Unfortunately this does not throw for web compatibility.

<li><p><a>Adopt</a> <var>node</var> into <a>this</a>.

<li><p>Return <var>node</var>.
Expand Down

0 comments on commit 9a1e814

Please sign in to comment.