Skip to content

Commit e3c3983

Browse files
Jayson Chenannevk
authored andcommitted
Update element adoption logic for scoped registries
Fixes #1429 by making sure elements get the correct scoped custom element registry upon adoption.
1 parent 995b4c3 commit e3c3983

1 file changed

Lines changed: 47 additions & 17 deletions

File tree

dom.bs

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4944,7 +4944,7 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume
49444944

49454945
<li><p>If <var>shadowRootRegistry</var> <a>is a global custom element registry</a>, then set
49464946
<var>shadowRootRegistry</var> to <var>document</var>'s
4947-
<a>effective global custom element registry</a>.
4947+
<a for=Document>custom element registry</a>'s <a>effective global custom element registry</a>.
49484948

49494949
<li><p><a>Attach a shadow root</a> with <var>copy</var>, <var>node</var>'s
49504950
<a for=Element>shadow root</a>'s <a for=ShadowRoot>mode</a>, true, <var>node</var>'s
@@ -4993,7 +4993,8 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume
49934993
<var>fallbackRegistry</var>.
49944994

49954995
<li><p>If <var>registry</var> <a>is a global custom element registry</a>, then set
4996-
<var>registry</var> to <var>document</var>'s <a>effective global custom element registry</a>.
4996+
<var>registry</var> to <var>document</var>'s <a for=Document>custom element registry</a>'s
4997+
<a>effective global custom element registry</a>.
49974998

49984999
<li><p>Set <var>copy</var> to the result of <a>creating an element</a>, given
49995000
<var>document</var>, <var>node</var>'s <a for=Element>local name</a>, <var>node</var>'s
@@ -6119,7 +6120,8 @@ algorithm is passed <var ignore>node</var> and <var ignore>oldDocument</var>, as
61196120
</ul>
61206121

61216122
<p>then set <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> to
6122-
<var>document</var>'s <a>effective global custom element registry</a>.
6123+
<var>document</var>'s <a for=Document>custom element registry</a>'s
6124+
<a>effective global custom element registry</a>.
61236125

61246126
<li>
61256127
<p>Otherwise, if <var>inclusiveDescendant</var> is an <a for=/>element</a>:
@@ -6128,11 +6130,27 @@ algorithm is passed <var ignore>node</var> and <var ignore>oldDocument</var>, as
61286130
<li><p>Set the <a for=Node>node document</a> of each <a>attribute</a> in
61296131
<var>inclusiveDescendant</var>'s <a for=Element>attribute list</a> to <var>document</var>.
61306132

6131-
<li><p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is null
6132-
or <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>'s
6133-
<a for=CustomElementRegistry>is scoped</a> is false, then set
6134-
<var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> to
6135-
<var>document</var>'s <a>effective global custom element registry</a>.
6133+
<li>
6134+
<p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is null or
6135+
<var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>'s
6136+
<a for=CustomElementRegistry>is scoped</a> is false:
6137+
6138+
<ol>
6139+
<li><p>Let <var>registry</var> be null.
6140+
6141+
<li><p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is
6142+
non-null, <var>inclusiveDescendant</var>'s <a for=tree>parent</a> is null, or
6143+
<var>inclusiveDescendant</var>'s <a for=tree>parent</a> is an
6144+
<a>exclusive <code>DocumentFragment</code> node</a>, then set <var>registry</var> to
6145+
<var>document</var>'s <a for=Document>custom element registry</a>.
6146+
6147+
<li><p>Otherwise, set <var>registry</var> to the result of
6148+
<a for=/>looking up a custom element registry</a> given <var>inclusiveDescendant</var>'s
6149+
<a for=tree>parent</a>.
6150+
6151+
<li><p>Set <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> to
6152+
<var>registry</var>'s <a>effective global custom element registry</a>.
6153+
</ol>
61366154

61376155
<li><p>If <var>inclusiveDescendant</var> is <a for=Element>custom</a>, then
61386156
<a>enqueue a custom element callback reaction</a> with <var>inclusiveDescendant</var>, callback
@@ -6171,13 +6189,12 @@ algorithm is passed <var ignore>node</var> and <var ignore>oldDocument</var>, as
61716189
<dfn>is a global custom element registry</dfn> if <var>registry</var> is non-null and
61726190
<var>registry</var>'s <a for=CustomElementRegistry>is scoped</a> is false.
61736191

6174-
<p>A <a for=/>document</a> <var>document</var>'s <dfn>effective global custom element registry</dfn>
6175-
is:
6192+
<p>Null or a {{CustomElementRegistry}} object <var>registry</var>'s
6193+
<dfn>effective global custom element registry</dfn> is:
61766194

61776195
<ol>
6178-
<li><p>If <var>document</var>'s <a for=Document>custom element registry</a>
6179-
<a>is a global custom element registry</a>, then return <var>document</var>'s
6180-
<a for=Document>custom element registry</a>.
6196+
<li><p>If <var>registry</var> <a>is a global custom element registry</a>, then return
6197+
<var>registry</var>.
61816198

61826199
<li><p>Return null.
61836200
</ol>
@@ -6516,30 +6533,43 @@ interface DocumentFragment : Node {
65166533
};
65176534
</pre>
65186535

6536+
<dl class=domintro>
6537+
<dt><code><var ignore>tree</var> = new {{DocumentFragment()}}</code>
6538+
<dd>Returns a new {{DocumentFragment}} <a for=/>node</a>.
6539+
</dl>
6540+
6541+
<hr>
6542+
6543+
<div algorithm>
6544+
<p>An <dfn export>exclusive {{DocumentFragment}} node</dfn> is a {{DocumentFragment}}
6545+
<a for=/>node</a> that is not a {{ShadowRoot}} <a for=/>node</a>.
6546+
</div>
6547+
65196548
<p>A {{DocumentFragment}} <a for=/>node</a> has an associated
65206549
<dfn export id=concept-documentfragment-host for=DocumentFragment>host</dfn> (null or an
65216550
<a for=/>element</a> in a different <a>node tree</a>). It is null unless otherwise stated.
65226551

6552+
<div algorithm>
65236553
<p>An object <var>A</var> is a
65246554
<dfn export id=concept-tree-host-including-inclusive-ancestor>host-including inclusive ancestor</dfn>
65256555
of an object <var>B</var>, if either <var>A</var> is an <a for=tree>inclusive ancestor</a> of <var>B</var>,
65266556
or if <var>B</var>'s <a for=tree>root</a> has a non-null <a for=DocumentFragment>host</a> and
65276557
<var>A</var> is a <a>host-including inclusive ancestor</a> of <var>B</var>'s <a for=tree>root</a>'s
65286558
<a for=DocumentFragment>host</a>.
6559+
</div>
65296560

65306561
<p class=note>The {{DocumentFragment}} <a for=/>node</a>'s <a for=DocumentFragment>host</a>
65316562
concept is useful for HTML's <{template}> element and for <a for=/>shadow roots</a>, and impacts the
65326563
<a>pre-insert</a> and <a>replace</a> algorithms.
65336564

6534-
<dl class=domintro>
6535-
<dt><code><var ignore>tree</var> = new {{DocumentFragment()}}</code>
6536-
<dd>Returns a new {{DocumentFragment}} <a for=/>node</a>.
6537-
</dl>
6565+
<hr>
65386566

6567+
<div algorithm>
65396568
<p>The
65406569
<dfn constructor for=DocumentFragment lt=DocumentFragment()><code>new DocumentFragment()</code></dfn>
65416570
constructor steps are to set <a>this</a>'s <a for=Node>node document</a> to
65426571
<a>current global object</a>'s <a>associated <code>Document</code></a>.
6572+
</div>
65436573

65446574

65456575
<h3 id=interface-shadowroot>Interface {{ShadowRoot}}</h3>

0 commit comments

Comments
 (0)