Skip to content

Commit 7afc950

Browse files
committed
Make adoption account for DocumentFragment nodes with hosts
Tests: web-platform-tests/wpt#22504. Corresponding HTML PR: whatwg/html#5413. Closes #813 and closes #814.
1 parent 1b137ba commit 7afc950

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

dom.bs

+18-2
Original file line numberDiff line numberDiff line change
@@ -5329,8 +5329,8 @@ method steps are:
53295329
algorithm is passed <var>node</var> and <var>oldDocument</var>, as indicated in the <a>adopt</a>
53305330
algorithm.
53315331

5332-
<p>To <dfn export id=concept-node-adopt>adopt</dfn> a <var>node</var> into a <var>document</var>, run
5333-
these steps:
5332+
<p>To <dfn export id=concept-node-adopt>adopt</dfn> a <var>node</var> into a <var>document</var>,
5333+
with an optional <var>forceDocumentFragmentAdoption</var> (default false):
53345334

53355335
<ol>
53365336
<li><p>Let <var>oldDocument</var> be <var>node</var>'s <a for=Node>node document</a>.
@@ -5347,6 +5347,16 @@ these steps:
53475347
<a>shadow-including inclusive descendants</a>:
53485348

53495349
<ol>
5350+
<li>
5351+
<p>If <var>forceDocumentFragmentAdoption</var> is false, <var>inclusiveDescendant</var> is a
5352+
{{DocumentFragment}} <a for=/>node</a>, <var>inclusiveDescendant</var> is <var>node</var>, and
5353+
<var>node</var>'s <a for=DocumentFragment>host</a> is non-null, then
5354+
<a for=iteration>continue</a>.
5355+
5356+
<p class=note>This is only reasonable as long as all <a>adopt</a> callers remove the children
5357+
of <var>node</var>. HTML's <{template}> element passes true for
5358+
<var>forceDocumentFragmentAdoption</var>.
5359+
53505360
<li><p>Set <var>inclusiveDescendant</var>'s <a for=Node>node document</a> to <var>document</var>.
53515361

53525362
<li><p>If <var>inclusiveDescendant</var> is an <a for=/>element</a>, then set the
@@ -5375,6 +5385,12 @@ these steps:
53755385
<li><p>If <var>node</var> is a <a for=/>shadow root</a>, then <a>throw</a> a
53765386
"{{HierarchyRequestError!!exception}}" {{DOMException}}.
53775387

5388+
<li>
5389+
<p>If <var>node</var> is a {{DocumentFragment}} <a for=/>node</a> and its
5390+
<a for=DocumentFragment>host</a> is non-null, then return <var>node</var>.
5391+
5392+
<p class=note>Unfortunately this does not throw for web compatibility.
5393+
53785394
<li><p><a>Adopt</a> <var>node</var> into <a>this</a>.
53795395

53805396
<li><p>Return <var>node</var>.

0 commit comments

Comments
 (0)