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: web-platform-tests/wpt#22504.

Corresponding HTML PR: whatwg/html#5413.

Closes #813 and closes #814.
  • Loading branch information
annevk committed Oct 18, 2022
1 parent 1b137ba commit 7afc950
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -5329,8 +5329,8 @@ method steps are:
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> (default false):

<ol>
<li><p>Let <var>oldDocument</var> be <var>node</var>'s <a for=Node>node document</a>.
Expand All @@ -5347,6 +5347,16 @@ 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>. HTML's <{template}> element passes true for
<var>forceDocumentFragmentAdoption</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 @@ -5375,6 +5385,12 @@ 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 7afc950

Please sign in to comment.