Skip to content

Commit d1bdc30

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 858fa1e commit d1bdc30

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
@@ -4872,7 +4872,7 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume
48724872

48734873
<li><p>If <var>shadowRootRegistry</var> <a>is a global custom element registry</a>, then set
48744874
<var>shadowRootRegistry</var> to <var>document</var>'s
4875-
<a>effective global custom element registry</a>.
4875+
<a for=Document>custom element registry</a>'s <a>effective global custom element registry</a>.
48764876

48774877
<li><p><a>Attach a shadow root</a> with <var>copy</var>, <var>node</var>'s
48784878
<a for=Element>shadow root</a>'s <a for=ShadowRoot>mode</a>, true, <var>node</var>'s
@@ -4917,7 +4917,8 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume
49174917
<var>fallbackRegistry</var>.
49184918

49194919
<li><p>If <var>registry</var> <a>is a global custom element registry</a>, then set
4920-
<var>registry</var> to <var>document</var>'s <a>effective global custom element registry</a>.
4920+
<var>registry</var> to <var>document</var>'s <a for=Document>custom element registry</a>'s
4921+
<a>effective global custom element registry</a>.
49214922

49224923
<li><p>Set <var>copy</var> to the result of <a>creating an element</a>, given
49234924
<var>document</var>, <var>node</var>'s <a for=Element>local name</a>, <var>node</var>'s
@@ -6047,7 +6048,8 @@ algorithm is passed <var ignore>node</var> and <var ignore>oldDocument</var>, as
60476048
</ul>
60486049

60496050
<p>then set <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> to
6050-
<var>document</var>'s <a>effective global custom element registry</a>.
6051+
<var>document</var>'s <a for=Document>custom element registry</a>'s
6052+
<a>effective global custom element registry</a>.
60516053

60526054
<li>
60536055
<p>Otherwise, if <var>inclusiveDescendant</var> is an <a for=/>element</a>:
@@ -6056,11 +6058,27 @@ algorithm is passed <var ignore>node</var> and <var ignore>oldDocument</var>, as
60566058
<li><p>Set the <a for=Node>node document</a> of each <a>attribute</a> in
60576059
<var>inclusiveDescendant</var>'s <a for=Element>attribute list</a> to <var>document</var>.
60586060

6059-
<li><p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is null
6060-
or <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>'s
6061-
<a for=CustomElementRegistry>is scoped</a> is false, then set
6062-
<var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> to
6063-
<var>document</var>'s <a>effective global custom element registry</a>.
6061+
<li>
6062+
<p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is null or
6063+
<var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>'s
6064+
<a for=CustomElementRegistry>is scoped</a> is false:
6065+
6066+
<ol>
6067+
<li><p>Let <var>registry</var> be null.
6068+
6069+
<li><p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is
6070+
non-null, <var>inclusiveDescendant</var>'s <a for=tree>parent</a> is null, or
6071+
<var>inclusiveDescendant</var>'s <a for=tree>parent</a> is an
6072+
<a>exclusive <code>DocumentFragment</code> node</a>, then set <var>registry</var> to
6073+
<var>document</var>'s <a for=Document>custom element registry</a>.
6074+
6075+
<li><p>Otherwise, set <var>registry</var> to the result of
6076+
<a for=/>looking up a custom element registry</a> given <var>inclusiveDescendant</var>'s
6077+
<a for=tree>parent</a>.
6078+
6079+
<li><p>Set <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> to
6080+
<var>registry</var>'s <a>effective global custom element registry</a>.
6081+
</ol>
60646082

60656083
<li><p>If <var>inclusiveDescendant</var> is <a for=Element>custom</a>, then
60666084
<a>enqueue a custom element callback reaction</a> with <var>inclusiveDescendant</var>, callback
@@ -6099,13 +6117,12 @@ algorithm is passed <var ignore>node</var> and <var ignore>oldDocument</var>, as
60996117
<dfn>is a global custom element registry</dfn> if <var>registry</var> is non-null and
61006118
<var>registry</var>'s <a for=CustomElementRegistry>is scoped</a> is false.</p>
61016119

6102-
<p>A <a for=/>document</a> <var>document</var>'s <dfn>effective global custom element registry</dfn>
6103-
is:
6120+
<p>Null or a {{CustomElementRegistry}} object <var>registry</var>'s
6121+
<dfn>effective global custom element registry</dfn> is:
61046122

61056123
<ol>
6106-
<li><p>If <var>document</var>'s <a for=Document>custom element registry</a>
6107-
<a>is a global custom element registry</a>, then return <var>document</var>'s
6108-
<a for=Document>custom element registry</a>.
6124+
<li><p>If <var>registry</var> <a>is a global custom element registry</a>, then return
6125+
<var>registry</var>.
61096126

61106127
<li><p>Return null.
61116128
</ol>
@@ -6449,30 +6466,43 @@ interface DocumentFragment : Node {
64496466
};
64506467
</pre>
64516468

6469+
<dl class=domintro>
6470+
<dt><code><var ignore>tree</var> = new {{DocumentFragment()}}</code>
6471+
<dd>Returns a new {{DocumentFragment}} <a for=/>node</a>.
6472+
</dl>
6473+
6474+
<hr>
6475+
6476+
<div algorithm>
6477+
<p>An <dfn export>exclusive {{DocumentFragment}} node</dfn> is a {{DocumentFragment}}
6478+
<a for=/>node</a> that is not a {{ShadowRoot}} <a for=/>node</a>.
6479+
</div>
6480+
64526481
<p>A {{DocumentFragment}} <a for=/>node</a> has an associated
64536482
<dfn export id=concept-documentfragment-host for=DocumentFragment>host</dfn> (null or an
64546483
<a for=/>element</a> in a different <a>node tree</a>). It is null unless otherwise stated.
64556484

6485+
<div algorithm>
64566486
<p>An object <var>A</var> is a
64576487
<dfn export id=concept-tree-host-including-inclusive-ancestor>host-including inclusive ancestor</dfn>
64586488
of an object <var>B</var>, if either <var>A</var> is an <a for=tree>inclusive ancestor</a> of <var>B</var>,
64596489
or if <var>B</var>'s <a for=tree>root</a> has a non-null <a for=DocumentFragment>host</a> and
64606490
<var>A</var> is a <a>host-including inclusive ancestor</a> of <var>B</var>'s <a for=tree>root</a>'s
64616491
<a for=DocumentFragment>host</a>.
6492+
</div>
64626493

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

6467-
<dl class=domintro>
6468-
<dt><code><var ignore>tree</var> = new {{DocumentFragment()}}</code>
6469-
<dd>Returns a new {{DocumentFragment}} <a for=/>node</a>.
6470-
</dl>
6498+
<hr>
64716499

6500+
<div algorithm>
64726501
<p>The
64736502
<dfn constructor for=DocumentFragment lt=DocumentFragment()><code>new DocumentFragment()</code></dfn>
64746503
constructor steps are to set <a>this</a>'s <a for=Node>node document</a> to
64756504
<a>current global object</a>'s <a>associated <code>Document</code></a>.
6505+
</div>
64766506

64776507

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

0 commit comments

Comments
 (0)