Skip to content

Commit 8dafaf7

Browse files
committed
Make adoption account for DocumentFragment nodes with hosts
Tests: ... Corresponding HTML PR: ... Closes #813 and closes #814.
1 parent 6eb77d0 commit 8dafaf7

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

dom.bs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5260,10 +5260,15 @@ when invoked, must run these steps:
52605260
algorithm is passed <var>node</var> and <var>oldDocument</var>, as indicated in the <a>adopt</a>
52615261
algorithm.
52625262

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

52665266
<ol>
5267+
<li>
5268+
<p>If <var>forceDocumentFragmentAdoption</var> is not given, then set it false.
5269+
5270+
<p class=note>This is needed for HTML's <{template}> element.
5271+
52675272
<li><p>Let <var>oldDocument</var> be <var>node</var>'s <a for=Node>node document</a>.
52685273

52695274
<li><p>If <var>node</var>'s <a for=tree>parent</a> is non-null, then <a for=/>remove</a>
@@ -5278,6 +5283,15 @@ these steps:
52785283
<a>shadow-including inclusive descendants</a>:
52795284

52805285
<ol>
5286+
<li>
5287+
<p>If <var>forceDocumentFragmentAdoption</var> is false, <var>inclusiveDescendant</var> is a
5288+
{{DocumentFragment}} <a for=/>node</a>, <var>inclusiveDescendant</var> is <var>node</var>, and
5289+
<var>node</var>'s <a for=DocumentFragment>host</a> is non-null, then
5290+
<a for=iteration>continue</a>.
5291+
5292+
<p class=note>This is only reasonable as long as all <a>adopt</a> callers remove the children
5293+
of <var>node</var>.
5294+
52815295
<li><p>Set <var>inclusiveDescendant</var>'s <a for=Node>node document</a> to <var>document</var>.
52825296

52835297
<li><p>If <var>inclusiveDescendant</var> is an <a for=/>element</a>, then set the
@@ -5307,6 +5321,12 @@ must run these steps:
53075321
<li><p>If <var>node</var> is a <a for=/>shadow root</a>, then <a>throw</a> a
53085322
"{{HierarchyRequestError!!exception}}" {{DOMException}}.
53095323

5324+
<li>
5325+
<p>If <var>node</var> is a {{DocumentFragment}} <a for=/>node</a> and its
5326+
<a for=DocumentFragment>host</a> is non-null, then return <var>node</var>.
5327+
5328+
<p class=note>Unfortunately this does not throw for web compatibility.
5329+
53105330
<li><p><a>Adopt</a> <var>node</var> into <a>this</a>.
53115331

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

0 commit comments

Comments
 (0)