@@ -3203,7 +3203,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
3203
3203
<li><dfn data-x-href="https://dom.spec.whatwg.org/#concept-node-document">node document</dfn> concept</li>
3204
3204
<li><dfn data-x="concept-document-type" data-x-href="https://dom.spec.whatwg.org/#concept-document-type">document type</dfn> concept</li>
3205
3205
<li><dfn data-x="concept-DocumentFragment-host" data-x-href="https://dom.spec.whatwg.org/#concept-documentfragment-host">host</dfn> concept</li>
3206
- <li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-root">shadow root</dfn> concept, and its <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus">delegates focus</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals">available to element internals</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-clonable">clonable</dfn>, and <dfn data-x="shadow-serializable" data-x-href="https://dom.spec.whatwg.org/#shadowroot-serializable">serializable</dfn>.</li>
3206
+ <li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-root">shadow root</dfn> concept, and its <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus">delegates focus</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals">available to element internals</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-clonable">clonable</dfn>, <dfn data-x="shadow-serializable" data-x-href="https://dom.spec.whatwg.org/#shadowroot-serializable">serializable</dfn>, <dfn data-x="shadow-root-custom-element-registry" data-x-href="https://whatpr.org/dom/1341.html#shadowroot-custom-element-registry">custom element registry</dfn>, and <dfn data-x-href="https://whatpr.org/dom/1341.html#shadowroot-keep-custom-element-registry-null">keep custom element registry null</dfn>.</li>
3207
+ <!-- XXX xref -->
3207
3208
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#element-shadow-host">shadow host</dfn> concept</li>
3208
3209
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-htmlcollection"><code>HTMLCollection</code></dfn> interface, its
3209
3210
<dfn data-x="dom-HTMLCollection-length" data-x-href="https://dom.spec.whatwg.org/#dom-htmlcollection-length"><code>length</code></dfn> attribute, and its
@@ -3319,8 +3320,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
3319
3320
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-document-no-quirks">no-quirks mode</dfn></li>
3320
3321
<li>The algorithm <dfn data-x="concept-node-clone" data-x-href="https://dom.spec.whatwg.org/#concept-node-clone">clone a node</dfn> with its arguments
3321
3322
<dfn data-x="concept-node-clone-document" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-document"><var>document</var></dfn>,
3322
- <dfn data-x="concept-node-clone-subtree" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-subtree"><var>subtree</var></dfn>, and
3323
- <dfn data-x="concept-node-clone-parent" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-parent"><var>parent</var></dfn>, and the concept of
3323
+ <dfn data-x="concept-node-clone-subtree" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-subtree"><var>subtree</var></dfn>,
3324
+ <dfn data-x="concept-node-clone-parent" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-parent"><var>parent</var></dfn>, and
3325
+ <dfn data-x="concept-node-clone-fallbackRegistry" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-fallbackregistry"><var>fallbackRegistry</var></dfn>, and the concept of
3324
3326
<dfn data-x="concept-node-clone-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-clone-ext">cloning steps</dfn></li>
3325
3327
<li>The concept of <dfn>base URL change steps</dfn> and the definition of what happens when an element is <dfn>affected by a base URL change</dfn></li>
3326
3328
<li>The concept of an element's <dfn data-x="concept-id" data-x-href="https://dom.spec.whatwg.org/#concept-id">unique identifier (ID)</dfn></li>
@@ -3341,6 +3343,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
3341
3343
<li>An element's <dfn data-x="concept-element-namespace" data-x-href="https://dom.spec.whatwg.org/#concept-element-namespace">namespace</dfn>,
3342
3344
<dfn data-x="concept-element-namespace-prefix" data-x-href="https://dom.spec.whatwg.org/#concept-element-namespace-prefix">namespace prefix</dfn>,
3343
3345
<dfn data-x="concept-element-local-name" data-x-href="https://dom.spec.whatwg.org/#concept-element-local-name">local name</dfn>,
3346
+ <dfn data-x="element-custom-element-registry" data-x-href="https://whatpr.org/dom/1341.html#concept-element-custom-element-registry">custom element registry</dfn>,
3347
+ <!-- XXX xref -->
3344
3348
<dfn data-x="concept-element-custom-element-definition" data-x-href="https://dom.spec.whatwg.org/#concept-element-custom-element-definition">custom element definition</dfn>, and
3345
3349
<dfn data-x="concept-element-is-value" data-x-href="https://dom.spec.whatwg.org/#concept-element-is-value"><code data-x="">is</code> value</dfn></li>
3346
3350
@@ -12050,9 +12054,6 @@ console.assert(el.constructor === Element);</code></pre>
12050
12054
<span>overridden constructor steps</span>:</p>
12051
12055
12052
12056
<ol>
12053
- <li><p>Let <var>registry</var> be <span>current global object</span>'s <span
12054
- data-x="global-custom-element-registry">custom element registry</span>.</p></li>
12055
-
12056
12057
<li>
12057
12058
<p>If <span>NewTarget</span> is equal to the <span>active function
12058
12059
object</span>, then throw a <code>TypeError</code>.</p>
@@ -12073,6 +12074,24 @@ document.createElement("bad-1"); // (2)</code></pre>
12073
12074
</div>
12074
12075
</li>
12075
12076
12077
+ <li><p>Let <var>registry</var> be null.</p></li>
12078
+
12079
+ <li>
12080
+ <p>If the <span>surrounding agent</span>'s <span>active custom element constructor
12081
+ map</span>[<span>NewTarget</span>] <span data-x="map exists">exists</span>:</p>
12082
+
12083
+ <ol>
12084
+ <li><p>Set <var>registry</var> to the <span>surrounding agent</span>'s <span>active custom
12085
+ element constructor map</span>[<span>NewTarget</span>].</p></li>
12086
+
12087
+ <li><p><span data-x="map remove">Remove</span> the <span>surrounding agent</span>'s
12088
+ <span>active custom element constructor map</span>[<span>NewTarget</span>].</p></li>
12089
+ </ol>
12090
+
12091
+ <li><p>If <var>registry</var> is null, then set <var>registry</var> to <span>current global
12092
+ object</span>'s <span data-x="global-custom-element-registry">custom element
12093
+ registry</span>.</p></li>
12094
+
12076
12095
<li>
12077
12096
<p>Let <var>definition</var> be the item in <var>registry</var>'s <span>custom element
12078
12097
definition set</span> with <span
@@ -64660,6 +64679,7 @@ not-slash = %x0000-002E / %x0030-10FFFF
64660
64679
<dd><code data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</code></dd>
64661
64680
<dd><code data-x="attr-template-shadowrootclonable">shadowrootclonable</code></dd>
64662
64681
<dd><code data-x="attr-template-shadowrootserializable">shadowrootserializable</code></dd>
64682
+ <dd><code data-x="attr-template-shadowrootcustomelements">shadowrootcustomelements</code></dd>
64663
64683
<dt><span
64664
64684
data-x="concept-element-accessibility-considerations">Accessibility considerations</span>:</dt>
64665
64685
<dd><a href="https://w3c.github.io/html-aria/#el-template">For authors</a>.</dd>
@@ -64675,6 +64695,7 @@ interface <dfn interface>HTMLTemplateElement</dfn> : <span>HTMLElement</span> {
64675
64695
[<span>CEReactions</span>] attribute boolean <span data-x="dom-template-shadowrootdelegatesfocus">shadowRootDelegatesFocus</span>;
64676
64696
[<span>CEReactions</span>] attribute boolean <span data-x="dom-template-shadowrootclonable">shadowRootClonable</span>;
64677
64697
[<span>CEReactions</span>] attribute boolean <span data-x="dom-template-shadowRootSerializable">shadowRootSerializable</span>;
64698
+ [<span>CEReactions</span>] attribute DOMString <span data-x="dom-template-shadowRootCustomElements">shadowRootCustomElements</span>;
64678
64699
};</code></pre>
64679
64700
</dd>
64680
64701
<dd w-dev>Uses <code>HTMLTemplateElement</code>.</dd>
@@ -64723,6 +64744,10 @@ interface <dfn interface>HTMLTemplateElement</dfn> : <span>HTMLElement</span> {
64723
64744
data-x="attr-template-shadowrootserializable">shadowrootserializable</code></dfn> content
64724
64745
attribute is a <span>boolean attribute</span>.</p>
64725
64746
64747
+ <p>The <dfn element-attr for="template"><code
64748
+ data-x="attr-template-shadowrootcustomelements">shadowrootcustomelements</code></dfn>
64749
+ content attribute is a <span>boolean attribute</span>.</p>
64750
+
64726
64751
<p>The <span>template contents</span> of a <code>template</code> element <a
64727
64752
href="#template-syntax">are not children of the element itself</a>.</p>
64728
64753
@@ -64875,6 +64900,15 @@ interface <dfn interface>HTMLTemplateElement</dfn> : <span>HTMLElement</span> {
64875
64900
must <span>reflect</span> the <code
64876
64901
data-x="attr-template-shadowrootserializable">shadowrootserializable</code> content attribute.</p>
64877
64902
64903
+ <p>The <dfn attribute for="HTMLTemplateElement"><code
64904
+ data-x="dom-template-shadowRootCustomElements">shadowRootCustomElements</code></dfn> IDL attribute
64905
+ must <span>reflect</span> the <code
64906
+ data-x="attr-template-shadowrootcustomelements">shadowrootcustomelements</code> content
64907
+ attribute.</p>
64908
+
64909
+ <p class="note">The IDL attribute does intentionally not have a boolean type so it can be
64910
+ extended.</p>
64911
+
64878
64912
<hr>
64879
64913
64880
64914
<p>The <span data-x="concept-node-clone-ext">cloning steps</span> for <code>template</code>
@@ -73223,8 +73257,8 @@ document.body.append(parent);
73223
73257
73224
73258
<div w-nodev>
73225
73259
73226
- <p>A <dfn>custom element definition</dfn> describes a <span>custom element</span> and consists
73227
- of:</p>
73260
+ <p>A <dfn export >custom element definition</dfn> describes a <span>custom element</span> and
73261
+ consists of:</p>
73228
73262
73229
73263
<dl>
73230
73264
<dt>A <dfn data-x="concept-custom-element-definition-name" export
@@ -73278,18 +73312,15 @@ document.body.append(parent);
73278
73312
<dd>Controls <code data-x="dom-Element-attachShadow">attachShadow()</code>.
73279
73313
</dl>
73280
73314
73281
- <p>To <dfn export>look up a custom element definition</dfn>, given a <var>document</var>,
73282
- <var>namespace</var>, <var>localName</var>, and <var>is</var>, perform the following steps. They
73283
- will return either a <span>custom element definition</span> or null:</p>
73315
+ <p>To <dfn export>look up a custom element definition</dfn>, given null or a
73316
+ <code>CustomElementRegistry</code> object <var>registry</var>, string-or-null
73317
+ <var>namespace</var>, string <var>localName</var>, and string-or-null <var>is</var>, perform the
73318
+ following steps. They will return either a <span>custom element definition</span> or null:</p>
73284
73319
73285
73320
<ol>
73286
- <li><p>If <var>namespace</var> is not the <span>HTML namespace</span>, then return null.</p></li>
73287
-
73288
- <li><p>If <var>document</var>'s <span data-x="concept-document-bc">browsing context</span> is
73289
- null, then return null.</p></li>
73321
+ <li><p>If <var>registry</var> is null, then return null.</p></li>
73290
73322
73291
- <li><p>Let <var>registry</var> be <var>document</var>'s <span>relevant global object</span>'s
73292
- <span data-x="global-custom-element-registry">custom element registry</span>.</p></li>
73323
+ <li><p>If <var>namespace</var> is not the <span>HTML namespace</span>, then return null.</p></li>
73293
73324
73294
73325
<li><p>If <var>registry</var>'s <span>custom element definition set</span> <span data-x="list
73295
73326
contains">contains</span> an item with <span
@@ -73322,18 +73353,28 @@ document.body.append(parent);
73322
73353
73323
73354
<div w-nodev>
73324
73355
73356
+ <p>Each <span>similar-origin window agent</span> has an associated <dfn export for="similar-origin
73357
+ window agent">active custom element constructor map</dfn>, which is a <span data-x="ordered
73358
+ map">map</span> of constructors to <code>CustomElementRegistry</code> objects.</p>
73359
+
73325
73360
<p>The <dfn attribute for="Window"><code
73326
73361
data-x="dom-window-customElements">customElements</code></dfn> attribute of the
73327
73362
<code>Window</code> interface must return the <code>CustomElementRegistry</code> object for that
73328
73363
<code>Window</code> object.</p>
73329
73364
73330
73365
<pre><code class="idl">[Exposed=Window]
73331
73366
interface <dfn interface>CustomElementRegistry</dfn> {
73332
- [<span>CEReactions</span>] undefined <span data-x="dom-CustomElementRegistry-define">define</span>(DOMString name, <span>CustomElementConstructor</span> constructor, optional <span>ElementDefinitionOptions</span> options = {});
73333
- (<span>CustomElementConstructor</span> or undefined) <span data-x="dom-CustomElementRegistry-get">get</span>(DOMString name);
73334
- DOMString? <span data-x="dom-CustomElementRegistry-getName">getName</span>(CustomElementConstructor constructor);
73335
- <span data-x="idl-Promise">Promise</span><<span>CustomElementConstructor</span>> <span data-x="dom-CustomElementRegistry-whenDefined">whenDefined</span>(DOMString name);
73336
- [<span>CEReactions</span>] undefined <span data-x="dom-CustomElementRegistry-upgrade">upgrade</span>(<span>Node</span> root);
73367
+ <span data-x="dom-CustomElementRegistry">constructor</span>();
73368
+
73369
+ [<span>CEReactions</span>] undefined <span data-x="dom-CustomElementRegistry-define">define</span>(DOMString <var>name</var>, <span>CustomElementConstructor</span> <var>constructor</var>, optional <span>ElementDefinitionOptions</span> <var>options</var> = {});
73370
+ (<span>CustomElementConstructor</span> or undefined) <span data-x="dom-CustomElementRegistry-get">get</span>(DOMString <var>name</var>);
73371
+ DOMString? <span data-x="dom-CustomElementRegistry-getName">getName</span>(CustomElementConstructor <var>constructor</var>);
73372
+ <span data-x="idl-Promise">Promise</span><<span>CustomElementConstructor</span>> <span data-x="dom-CustomElementRegistry-whenDefined">whenDefined</span>(DOMString <var>name</var>);
73373
+ [<span>CEReactions</span>] undefined <span data-x="dom-CustomElementRegistry-upgrade">upgrade</span>(<span>Node</span> <var>root</var>);
73374
+
73375
+ [<span>CEReactions</span>, NewObject] <span>HTMLElement</span> <span data-x="dom-CustomElementRegistry-createElement">createElement</span>(DOMString <var>name</var>);
73376
+ [<span>CEReactions</span>, NewObject] <span>Node</span> <span data-x="dom-CustomElementRegistry-cloneSubtree">cloneSubtree</span>(<span>Node</span> <var>root</var>);
73377
+ undefined <span data-x="dom-CustomElementRegistry-initializeSubtree">initializeSubtree</span>((<span>Element</span> or <span>ShadowRoot</span>) <var>root</var>);
73337
73378
};
73338
73379
73339
73380
callback <dfn callback>CustomElementConstructor</dfn> = <span>HTMLElement</span> ();
@@ -73342,6 +73383,12 @@ dictionary <dfn dictionary>ElementDefinitionOptions</dfn> {
73342
73383
DOMString <dfn dict-member for="ElementDefinitionOptions" data-x="dom-ElementDefinitionOptions-extends">extends</dfn>;
73343
73384
};</code></pre>
73344
73385
73386
+ <p>Every <code>CustomElementRegistry</code> has an <dfn export for="CustomElementRegistry">is
73387
+ scoped</dfn>, a boolean, initially false.</p>
73388
+
73389
+ <p>Every <code>CustomElementRegistry</code> has a <dfn export for="CustomElementRegistry">scoped
73390
+ document set</dfn>, a <span>set</span> of <code>Document</code> objects, initially « ».</p>
73391
+
73345
73392
<p>Every <code>CustomElementRegistry</code> has a <dfn>custom element definition set</dfn>, a
73346
73393
<span>set</span> of <span data-x="custom element definition">custom element definitions</span>,
73347
73394
initially « ». Lookup of items in this <span>set</span> uses their <span
@@ -73358,50 +73405,90 @@ dictionary <dfn dictionary>ElementDefinitionOptions</dfn> {
73358
73405
element names</span> to promises. It is used to implement the <code
73359
73406
data-x="dom-CustomElementRegistry-whenDefined">whenDefined()</code> method.</p>
73360
73407
73408
+ <p>To <dfn export>look up a custom element registry</dfn>, given an <code>Element</code> object,
73409
+ <code>ShadowRoot</code> object, or <code>Document</code> object <var>parentNode</var>:
73410
+
73411
+ <ol>
73412
+ <li><p>If <var>parentNode</var> is an <code>Element</code> object, then return
73413
+ <var>parentNode</var>'s <span data-x="element-custom-element-registry">custom element
73414
+ registry</span>.
73415
+
73416
+ <li><p>If <var>parentNode</var> is a <code>ShadowRoot</code> object, then return
73417
+ <var>parentNode</var>'s <span data-x="shadow-root-custom-element-registry">custom element
73418
+ registry</span>.
73419
+
73420
+ <li><p>If <var>parentNode</var>'s <span data-x="concept-document-bc">browsing context</span> is
73421
+ null, then return null.</p></li>
73422
+
73423
+ <li><p>Return <var>parentNode</var>'s <span>relevant global object</span>'s <span
73424
+ data-x="global-custom-element-registry">custom element registry</span>.</p></li>
73425
+ </ol>
73426
+
73361
73427
</div>
73362
73428
73363
73429
<dl class="domintro">
73364
- <dt><code data-x=""><var>window</var>.<span data-x="dom-window-customElements">customElements</span>.<span subdfn data-x="dom-CustomElementRegistry-define">define</span>(<var>name</var>,
73365
- <var>constructor</var>)</code></dt>
73430
+ <dt><code data-x=""><var>registry</var> = <var>window</var>.<span subdfn data-x="dom-window-customElements">customElements</span></code></dt>
73431
+ <dd>Returns the global <code>CustomElementRegistry</code> object.</dd>
73432
+
73433
+ <dt><code data-x=""><var>registry</var> = new <span subdfn data-x="dom-CustomElementRegistry">CustomElementRegistry</span>()</code></dt>
73434
+ <dd>Constructs a new <code>CustomElementRegistry</code> object, for scoped usage.</dd>
73366
73435
73436
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-define">define</span>(<var>name</var>,
73437
+ <var>constructor</var>)</code></dt>
73367
73438
<dd>Defines a new <span>custom element</span>, mapping the given name to the given constructor
73368
73439
as an <span>autonomous custom element</span>.</dd>
73369
73440
73370
-
73371
- <dt><code data-x=""><var>window</var>.<span data-x="dom-window-customElements">customElements</span>.<span data-x="dom-CustomElementRegistry-define">define</span>(<var>name</var>, <var>constructor</var>,
73441
+ <dt><code data-x=""><var>registry</var>.<span data-x="dom-CustomElementRegistry-define">define</span>(<var>name</var>, <var>constructor</var>,
73372
73442
{ extends: <var>baseLocalName</var> })</code></dt>
73373
-
73374
73443
<dd>Defines a new <span>custom element</span>, mapping the given name to the given constructor as
73375
73444
a <span>customized built-in element</span> for the <span>element type</span> identified by the
73376
73445
supplied <var>baseLocalName</var>. A <span>"<code>NotSupportedError</code>"</span>
73377
73446
<code>DOMException</code> will be thrown upon trying to extend a <span>custom element</span> or
73378
- an unknown element.</dd>
73379
-
73380
- <dt><code data-x=""><var>window</var>.<span data-x="dom-window-customElements">customElements</span>.<span subdfn data-x="dom-CustomElementRegistry-get">get</span>(<var>name</var>)</code></dt>
73447
+ an unknown element, or when <var>registry</var> is not a global
73448
+ <code>CustomElementRegistry</code> object.</dd>
73381
73449
73450
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-get">get</span>(<var>name</var>)</code></dt>
73382
73451
<dd>Retrieves the <span>custom element constructor</span> defined for the given <span data-x="concept-custom-element-definition-name">name</span>. Returns undefined if there is no
73383
73452
<span>custom element definition</span> with the given <span data-x="concept-custom-element-definition-name">name</span>.</dd>
73384
73453
73385
- <dt><code data-x=""><var>window</var>.<span data-x="dom-window-customElements">customElements</span>.<span subdfn data-x="dom-CustomElementRegistry-getName">getName</span>(<var>constructor</var>)</code></dt>
73386
-
73454
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-getName">getName</span>(<var>constructor</var>)</code></dt>
73387
73455
<dd>Retrieves the given name for a <span>custom element</span> defined for the given <span data-x="concept-custom-element-definition-constructor">constructor</span>. Returns null if there is no
73388
73456
<span>custom element definition</span> with the given <span data-x="concept-custom-element-definition-constructor">constructor</span>.</dd>
73389
73457
73390
- <dt><code data-x=""><var>window</var>.<span data-x="dom-window-customElements">customElements</span>.<span subdfn data-x="dom-CustomElementRegistry-whenDefined">whenDefined</span>(<var>name</var>)</code></dt>
73391
-
73458
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-whenDefined">whenDefined</span>(<var>name</var>)</code></dt>
73392
73459
<dd>Returns a promise that will be fulfilled with the <span>custom element</span>'s constructor
73393
73460
when a <span>custom element</span> becomes defined with the given name. (If such a <span>custom
73394
73461
element</span> is already defined, the returned promise will be immediately fulfilled.) Returns a
73395
73462
promise rejected with a <span>"<code>SyntaxError</code>"</span> <code>DOMException</code> if not
73396
73463
given a <span>valid custom element name</span>.</dd>
73397
73464
73398
- <dt><code data-x=""><var>window</var>.<span data-x="dom-window-customElements">customElements</span>.<span subdfn data-x="dom-CustomElementRegistry-upgrade">upgrade</span>(<var>root</var>)</code></dt>
73399
-
73465
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-upgrade">upgrade</span>(<var>root</var>)</code></dt>
73400
73466
<dd><span data-x="concept-try-upgrade">Tries to upgrade</span> all <span>shadow-including
73401
73467
inclusive descendant</span> elements of <var>root</var>, even if they are not
73402
73468
<span>connected</span>.</dd>
73469
+
73470
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-createElement">createElement</span>(<var>name</var>)</code></dt>
73471
+ <dd>
73472
+ <p>Returns an <span data-x="HTML elements">HTML element</span> with <var>name</var> as its local
73473
+ name and <var>registry</var> as its registry.</p>
73474
+
73475
+ <p>If <var>name</var> does not match the <code data-x="xml-Name">Name</code> production an
73476
+ <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code> will be thrown.</p>
73477
+ </dd>
73478
+
73479
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-cloneSubtree">cloneSubtree</span>(<var>root</var>)</code></dt>
73480
+ <dd>Returns a copy of <var>root</var>, changing the registry from <var>root</var>'s inclusive
73481
+ descendants from null (if any) to <var>registry</var> in the process.</dd>
73482
+
73483
+ <dt><code data-x=""><var>registry</var>.<span subdfn data-x="dom-CustomElementRegistry-initializeSubtree">initializeSubtree</span>(<var>root</var>)</code></dt>
73484
+ <dd>Each <span>inclusive descendant</span> of <var>root</var> with a null registry will have it
73485
+ updated to this <code>CustomElementRegistry</code> object.</dd>
73403
73486
</dl>
73404
73487
73488
+ <p w-nodev>The <dfn
73489
+ data-x="dom-CustomElementRegistry"><code>new CustomElementRegistry()</code></dfn> constructor
73490
+ steps are to set <span>this</span>'s <span>is scoped</span> to true.</p>
73491
+
73405
73492
<p><dfn>Element definition</dfn> is a process of adding a <span>custom element definition</span>
73406
73493
to the <code>CustomElementRegistry</code>. This is accomplished by the <code
73407
73494
data-x="dom-CustomElementRegistry-define">define()</code> method. <span w-nodev>The <dfn method
@@ -73438,6 +73525,10 @@ dictionary <dfn dictionary>ElementDefinitionOptions</dfn> {
73438
73525
<p>If <var>extends</var> is not null:</p>
73439
73526
73440
73527
<ol>
73528
+ <li><p>If <span>this</span> is not <span>this</span>'s <span>relevant global object</span>'s
73529
+ <span data-x="global-custom-element-registry">custom element registry</span>, then throw a
73530
+ <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
73531
+
73441
73532
<li><p>If <var>extends</var> is a <span>valid custom element name</span>, then throw a
73442
73533
<span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
73443
73534
@@ -73576,22 +73667,14 @@ dictionary <dfn dictionary>ElementDefinitionOptions</dfn> {
73576
73667
<li><p><span data-x="set append">Append</span> <var>definition</var> to <span>this</span>'s
73577
73668
<span>custom element definition set</span>.</p></li>
73578
73669
73579
- <li><p>Let <var>document</var> be <span>this</span>'s <span>relevant global object</span>'s <span
73580
- data-x="concept-document-window">associated <code>Document</code></span>.</p></li>
73581
-
73582
- <li><p>Let <var>upgradeCandidates</var> be all elements that are <span data-x="shadow-including
73583
- descendant">shadow-including descendants</span> of <var>document</var>, whose namespace
73584
- is the <span>HTML namespace</span> and whose local name is <var>localName</var>, in
73585
- <span>shadow-including tree order</span>. Additionally, if <var>extends</var> is non-null, only
73586
- include elements whose <span data-x="concept-element-is-value"><code data-x="">is</code>
73587
- value</span> is equal to <var>name</var>.</p></li>
73588
-
73589
- <li><p>For each element <var>element</var> of <var>upgradeCandidates</var>, <span>enqueue a
73590
- custom element upgrade reaction</span> given <var>element</var> and
73591
- <var>definition</var>.</p></li>
73670
+ <li><p>If <span>this</span>'s <span>is scoped</span> is true, then for each <var>document</var>
73671
+ of <span>this</span>'s <span>scoped document set</span>: <span>upgrade particular elements within
73672
+ a document</span> given <var>document</var> and <var>localName</var>.
73592
73673
73593
- <!-- It is equivalent to just try to upgrade all elements in the document, and let "try to
73594
- upgrade" bail out, but this seems a bit more explicit. -->
73674
+ <li><p>Otherwise, <span>upgrade particular elements within a document</span> given
73675
+ <span>this</span>'s <span>relevant global object</span>'s <span
73676
+ data-x="concept-document-window">associated <code>Document</code></span>, <var>localName</var>,
73677
+ and <var>name</var>.</p></li>
73595
73678
73596
73679
<li>
73597
73680
<p>If <span>this</span>'s <span>when-defined promise map</span>[<var>name</var>] <span data-x="map
@@ -73607,6 +73690,25 @@ dictionary <dfn dictionary>ElementDefinitionOptions</dfn> {
73607
73690
</li>
73608
73691
</ol>
73609
73692
73693
+ <p>To <dfn>upgrade particular elements within a document</dfn> given a <code>Document</code>
73694
+ object <var>document</var>, a string <var>localName</var>, and optionally a string <var>name</var>
73695
+ (default <var>localName</var>):
73696
+
73697
+ <ol>
73698
+ <li><p>Let <var>upgradeCandidates</var> be all elements that are <span data-x="shadow-including
73699
+ descendant">shadow-including descendants</span> of <var>document</var>, whose namespace
73700
+ is the <span>HTML namespace</span> and whose local name is <var>localName</var>, in
73701
+ <span>shadow-including tree order</span>. Additionally, if <var>name</var> is not
73702
+ <var>localName</var>, only include elements whose <span data-x="concept-element-is-value"><code
73703
+ data-x="">is</code> value</span> is equal to <var>name</var>.</p></li>
73704
+
73705
+ <li><p>For each element <var>element</var> of <var>upgradeCandidates</var>: <span>enqueue a
73706
+ custom element upgrade reaction</span> given <var>element</var> and
73707
+ <var>definition</var>.</p></li>
73708
+ </ol>
73709
+ <!-- It is equivalent to just try to upgrade all elements in the document, and let "try to
73710
+ upgrade" bail out, but this seems a bit more explicit. -->
73711
+
73610
73712
<p>The <dfn method for="CustomElementRegistry"><code
73611
73713
data-x="dom-CustomElementRegistry-get">get(<var>name</var>)</code></dfn> method steps are:</p>
73612
73714
@@ -73686,9 +73788,9 @@ fetch(articleURL)
73686
73788
73687
73789
<div w-nodev>
73688
73790
73689
- <p>When invoked, the <dfn method for="CustomElementRegistry"><code
73690
- data-x="dom-CustomElementRegistry-upgrade">upgrade(<var>root</var>)</code></dfn> method must run
73691
- these steps :</p>
73791
+ <p>The <dfn method for="CustomElementRegistry"><code
73792
+ data-x="dom-CustomElementRegistry-upgrade">upgrade(<var>root</var>)</code></dfn> method steps
73793
+ are :</p>
73692
73794
73693
73795
<ol>
73694
73796
<li><p>Let <var>candidates</var> be a <span>list</span> of all of <var>root</var>'s
@@ -73720,6 +73822,59 @@ console.assert(el instanceof SpiderMan); // upgraded!</code></pre>
73720
73822
73721
73823
<div w-nodev>
73722
73824
73825
+ <p>The <dfn method for="CustomElementRegistry"><code
73826
+ data-x="dom-CustomElementRegistry-createElement">createElement(<var>name</var>)</code></dfn>
73827
+ method steps are:</p>
73828
+
73829
+ <ol>
73830
+ <li><p>If <var>name</var> does not match the XML <code data-x="xml-Name">Name</code> production,
73831
+ then throw an <span>"<code>InvalidCharacterError</code>"</span>
73832
+ <code>DOMException</code>.</p></li>
73833
+
73834
+ <li><p>Return the result of <span data-x="create an element">creating an element</span> given
73835
+ <span>this</span>'s <span>relevant global object</span>'s <span
73836
+ data-x="concept-document-window">associated <code>Document</code></span>, <var>name</var>, the
73837
+ <span>HTML namespace</span>, null, null, true, and <span>this</span>.</p></li>
73838
+ </ol>
73839
+
73840
+ <p>The <dfn method for="CustomElementRegistry"><code
73841
+ data-x="dom-CustomElementRegistry-cloneSubtree">cloneSubtree(<var>root</var>)</code></dfn>
73842
+ method steps are:</p>
73843
+
73844
+ <ol>
73845
+ <li><p>If <var>root</var> is a <code>Document</code> or <code>ShadowRoot</code> object, then
73846
+ throw a <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
73847
+
73848
+ <li><p>Return the result of <span data-x="concept-node-clone">cloning a node</span> given
73849
+ <var>root</var> with <span data-x="concept-node-clone-subtree"><i>subtree</i></span> set to true
73850
+ and <span data-x="concept-node-clone-fallbackRegistry"><i>fallbackRegistry</i></span> set
73851
+ <span>this</span>.</p></li>
73852
+ </ol>
73853
+
73854
+ <p>The <dfn method for="CustomElementRegistry"><code
73855
+ data-x="dom-CustomElementRegistry-initializeSubtree">initializeSubtree(<var>root</var>)</code></dfn>
73856
+ method steps are:</p>
73857
+
73858
+ <ol>
73859
+ <li>
73860
+ <p>For each <span>inclusive descendant</span> <var>inclusiveDescendant</var> of
73861
+ <var>root</var>:</p>
73862
+
73863
+ <ol>
73864
+ <li><p>If <var>inclusiveDescendant</var> is an <code>Element</code> node whose <span
73865
+ data-x="element-custom-element-registry">custom element registry</span> is null, then set
73866
+ <var>inclusiveDescendant</var>'s <span data-x="element-custom-element-registry">custom element
73867
+ registry</span> to <span>this</span>.</p></li>
73868
+
73869
+ <li><p>Otherwise, if <var>inclusiveDescendant</var> is a <code>ShadowRoot</code> node whose
73870
+ <span data-x="shadow-root-custom-element-registry">custom element registry</span> is null, set
73871
+ <var>inclusiveDescendant</var>'s <span data-x="shadow-root-custom-element-registry">custom
73872
+ element registry</span> to <span>this</span>.</p></li>
73873
+ </ol>
73874
+ </li>
73875
+ </ol>
73876
+
73877
+
73723
73878
<h4><dfn data-x="custom-element-upgrades">Upgrades</dfn></h4>
73724
73879
73725
73880
<p>To <dfn data-x="concept-upgrade-an-element" export>upgrade an element</dfn>, given as input a
@@ -73791,8 +73946,14 @@ customElements.define("x-foo", class extends HTMLElement {
73791
73946
<li><p>Let <var>C</var> be <var>definition</var>'s <span
73792
73947
data-x="concept-custom-element-definition-constructor">constructor</span>.</p></li>
73793
73948
73949
+ <li><p>Let <var>registry</var> be <var>element</var>'s <span
73950
+ data-x="element-custom-element-registry">custom element registry</span>.</p></li>
73951
+
73952
+ <li><p><span data-x="map set">Set</span> the <span>surrounding agent</span>'s <span>active custom
73953
+ element constructor map</span>[<var>C</var>] to <var>registry</var>.</p></li>
73954
+
73794
73955
<li>
73795
- <p>Run the following substeps while catching any exceptions:</p>
73956
+ <p>Run the following steps while catching any exceptions:</p>
73796
73957
73797
73958
<ol>
73798
73959
<li>
@@ -73834,10 +73995,18 @@ customElements.define("x-foo", class extends HTMLElement {
73834
73995
</li>
73835
73996
</ol>
73836
73997
73837
- <p>Then, perform the following substep , regardless of whether the above steps threw an exception
73998
+ <p>Then, perform the following steps , regardless of whether the above steps threw an exception
73838
73999
or not:</p>
73839
74000
73840
74001
<ol>
74002
+ <li>
74003
+ <p><span data-x="map remove">Remove</span> <var>registry</var>'s <span>relevant global
74004
+ object</span>'s <span>active custom element constructor map</span>[<var>C</var>].</p>
74005
+
74006
+ <p class="note">This is a no-op if <var>C</var> immediately calls <code
74007
+ data-x="">super()</code> as it ought to do.</p>
74008
+ </li>
74009
+
73841
74010
<li>
73842
74011
<p>Remove the last entry from the end of <var>definition</var>'s <span
73843
74012
data-x="concept-custom-element-definition-construction-stack">construction stack</span>.</p>
@@ -73893,15 +74062,16 @@ customElements.define("x-foo", class extends HTMLElement {
73893
74062
element state</span> to "<code data-x="">custom</code>".</p></li>
73894
74063
</ol>
73895
74064
73896
- <p>To <dfn data-x="concept-try-upgrade" export>try to upgrade an element</dfn>, given as input an
73897
- element <var>element</var>, run the following steps :</p>
74065
+ <p>To <dfn data-x="concept-try-upgrade" export>try to upgrade an element</dfn> given an element
74066
+ <var>element</var>:</p>
73898
74067
73899
74068
<ol>
73900
74069
<li><p>Let <var>definition</var> be the result of <span data-x="look up a custom element
73901
- definition">looking up a custom element definition</span> given <var>element</var>'s <span>node
73902
- document</span>, <var>element</var>'s namespace, <var>element</var>'s local name, and
73903
- <var>element</var>'s <span data-x="concept-element-is-value"><code data-x="">is</code>
73904
- value</span>.</p></li>
74070
+ definition">looking up a custom element definition</span> given <var>element</var>'s <span
74071
+ data-x="element-custom-element-registry">custom element registry</span>, <var>element</var>'s
74072
+ <span data-x="concept-element-namespace">namespace</span>, <var>element</var>'s <span
74073
+ data-x="concept-element-local-name">local name</span>, and <var>element</var>'s <span
74074
+ data-x="concept-element-is-value"><code data-x="">is</code> value</span>.</p></li>
73905
74075
73906
74076
<li><p>If <var>definition</var> is not null, then <span>enqueue a custom element upgrade
73907
74077
reaction</span> given <var>element</var> and <var>definition</var>.</p></li>
@@ -74255,9 +74425,10 @@ customElements.define("x-foo", class extends HTMLElement {
74255
74425
<code>DOMException</code>.</p></li>
74256
74426
74257
74427
<li><p>Let <var>definition</var> be the result of <span data-x="look up a custom element
74258
- definition">looking up a custom element definition</span> given <span>this</span>'s <span>node
74259
- document</span>, its namespace, its local name, and null as the <span
74260
- data-x="concept-element-is-value"><code data-x="">is</code> value</span>.</p></li>
74428
+ definition">looking up a custom element definition</span> given <span>this</span>'s <span
74429
+ data-x="element-custom-element-registry">custom element registry</span>, <span>this</span>'s
74430
+ <span data-x="concept-element-namespace">namespace</span>, <span>this</span>'s <span
74431
+ data-x="concept-element-local-name">local name</span>, and null.</p></li>
74261
74432
74262
74433
<li><p>If <var>definition</var> is null, then throw an
74263
74434
<span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
@@ -130214,8 +130385,11 @@ dictionary <dfn dictionary>StorageEventInit</dfn> : <span>EventInit</span> {
130214
130385
<li><p>Let <var>is</var> be the value of the "<code data-x="attr-is">is</code>" attribute in the
130215
130386
given token, if such an attribute exists, or null otherwise.</p></li>
130216
130387
130388
+ <li><p>Let <var>registry</var> be the result of <span data-x="look up a custom element
130389
+ registry">looking up a custom element registry</span> given <var>intended parent</var>.</p></li>
130390
+
130217
130391
<li><p>Let <var>definition</var> be the result of <span data-x="look up a custom element
130218
- definition">looking up a custom element definition</span> given <var>document </var>, <var>given
130392
+ definition">looking up a custom element definition</span> given <var>registry </var>, <var>given
130219
130393
namespace</var>, <var>local name</var>, and <var>is</var>.</p></li>
130220
130394
130221
130395
<li><p>Let <var>willExecuteScript</var> be true if <var>definition</var> is non-null and the
@@ -131120,7 +131294,8 @@ document.body.appendChild(text);
131120
131294
<li>
131121
131295
<p><span data-x="concept-attach-a-shadow-root">Attach a shadow root</span> with
131122
131296
<var>declarative shadow host element</var>, <var>mode</var>, <var>clonable</var>,
131123
- <var>serializable</var>, <var>delegatesFocus</var>, and "<code data-x="">named</code>".</p>
131297
+ <var>serializable</var>, <var>delegatesFocus</var>, "<code data-x="">named</code>", and
131298
+ <var>registry</var>.</p>
131124
131299
131125
131300
<p>If an exception is thrown, then catch it and:</p>
131126
131301
@@ -131144,6 +131319,10 @@ document.body.appendChild(text);
131144
131319
<var>shadow</var>.</p></li>
131145
131320
131146
131321
<li><p>Set <var>shadow</var>'s <span>available to element internals</span> to true.</p></li>
131322
+
131323
+ <li><p>If <var>template start tag</var> has a <code
131324
+ data-x="attr-template-shadowrootcustomelements">shadowrootcustomelements</code> attribute,
131325
+ then set <var>shadow</var>'s <span>keep custom element registry null</span> to true.</p></li>
131147
131326
</ol>
131148
131327
</li>
131149
131328
</ol>
@@ -134948,6 +135127,11 @@ document.body.appendChild(text);
134948
135127
<li><p>If <var>shadow</var>'s <span>clonable</span> is set, then append
134949
135128
"<code data-x=""> shadowrootclonable=""</code>".</p></li>
134950
135129
135130
+ <li><p>If <var>current node</var>'s <span data-x="element-custom-element-registry">custom
135131
+ element registry</span> is not <var>shadow</var>'s <span
135132
+ data-x="shadow-root-custom-element-registry">custom element registry</span>, then append
135133
+ "<code data-x=""> shadowrootcustomelements=""</code>".</p></li>
135134
+
134951
135135
<li><p>Append "<code data-x="">></code>".</p></li>
134952
135136
134953
135137
<li><p>Append the value of running the <span>HTML fragment serialization algorithm</span> with
@@ -135361,8 +135545,9 @@ console.assert(container.firstChild instanceof SuperP);
135361
135545
</li>
135362
135546
135363
135547
<li><p>Let <var>root</var> be the result of <span data-x="create an element">creating an
135364
- element</span> given <var>document</var>, "<code data-x="">html</code>", and the <span>HTML
135365
- namespace</span>.</p></li>
135548
+ element</span> given <var>document</var>, "<code data-x="">html</code>", the <span>HTML
135549
+ namespace</span>, null, null, false, and <var>context</var>'s <span
135550
+ data-x="element-custom-element-registry">custom element registry</span>.</p></li>
135366
135551
135367
135552
<li><p><span data-x="concept-node-append">Append</span> <var>root</var> to
135368
135553
<var>document</var>.</p></li>
@@ -142618,7 +142803,8 @@ interface <dfn interface>External</dfn> {
142618
142803
<code data-x="attr-template-shadowrootmode">shadowrootmode</code>;
142619
142804
<code data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</code>;
142620
142805
<code data-x="attr-template-shadowrootclonable">shadowrootclonable</code>;
142621
- <code data-x="attr-template-shadowrootserializable">shadowrootserializable</code></td>
142806
+ <code data-x="attr-template-shadowrootserializable">shadowrootserializable</code>;
142807
+ <code data-x="attr-template-shadowrootcustomelements">shadowrootcustomelements</code></td>
142622
142808
<td><code>HTMLTemplateElement</code></td>
142623
142809
</tr>
142624
142810
@@ -144102,6 +144288,11 @@ interface <dfn interface>External</dfn> {
144102
144288
<td> <code data-x="attr-template-shadowrootclonable">template</code>
144103
144289
<td> Sets <span>clonable</span> on a declarative shadow root
144104
144290
<td> <span>Boolean attribute</span>
144291
+ <tr>
144292
+ <th> <code data-x="">shadowrootcustomelements</code>
144293
+ <td> <code data-x="attr-template-shadowrootcustomelements">template</code>
144294
+ <td> Enables declarative shadow roots to indicate they will use a custom element registry
144295
+ <td> <span>Boolean attribute</span>
144105
144296
<tr>
144106
144297
<th> <code data-x="">shadowrootdelegatesfocus</code>
144107
144298
<td> <code data-x="attr-template-shadowrootdelegatesfocus">template</code>
0 commit comments