Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Scoped custom elements registries #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 51 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -66390,6 +66390,8 @@ document.body.append(parent);

<pre><code class="idl">[Exposed=Window]
interface <dfn>CustomElementRegistry</dfn> {
<span data-x="dom-CustomElementRegistry">constructor</span>();

[<span>CEReactions</span>] undefined <span data-x="dom-CustomElementRegistry-define">define</span>(DOMString name, <span>CustomElementConstructor</span> constructor, optional <span>ElementDefinitionOptions</span> options = {});
(<span>CustomElementConstructor</span> or undefined) <span data-x="dom-CustomElementRegistry-get">get</span>(DOMString name);
Promise&lt;<span>CustomElementConstructor</span>&gt; <span data-x="dom-CustomElementRegistry-whenDefined">whenDefined</span>(DOMString name);
Expand Down Expand Up @@ -66428,7 +66430,6 @@ dictionary <dfn>ElementDefinitionOptions</dfn> {
<dd>Defines a new <span>custom element</span>, mapping the given name to the given constructor as
an <span>autonomous custom element</span>.</dd>


<dt><var>window</var> . <code data-x="dom-window-customElements">customElements</code> . <code
data-x="dom-CustomElementRegistry-define">define</code>(<var>name</var>, <var>constructor</var>,
{ extends: <var>baseLocalName</var> })</dt>
Expand Down Expand Up @@ -66464,8 +66465,38 @@ dictionary <dfn>ElementDefinitionOptions</dfn> {
<span>connected</span>.</dd>
</dl>

<p>New instances of <code>CustomElementRegistry</code> can be defined and attached to a
<span>ShadowRoot</span> through the registry option from <code
data-x="dom-Element-attachShadow">attachShadow()</code>. Those instances are independent of the
instance available at <code data-x="dom-window-customElements">window.customElements</code>, as
the latter is attached to the
<span data-x="concept-document-window">associated <code>Document</code></span>.</p>

<dl class="domintro">
<dt><var>registry</var> = new <code data-x="dom-CustomElementRegistry">CustomElementRegistry</code>()</dt>

<dd>Defines a new <span data-x="dom-CustomElementRegistry">Registry</span> that can map an
independent set of <span data-x="dom-window-customElements">custom elements</span>, which is
not associated yet to any <span>ShadowRoot</span>.</dd>

<dt><var>registry</var> . <code data-x="dom-CustomElementRegistry-define">define</code>(<var>name</var>,
<var>constructor</var>)</dt>

<dd>Defines a new <span>custom element</span> within the given <code data-x="">registry</code>,
mapping the given name to the given constructor as an <span>autonomous custom element</span>.
</dd>
</dl>

<p>When the <dfn><code data-x="dom-CustomElementRegistry">CustomElementRegistry()</code></dfn>
constructor is invoked, the user agent must run the following steps:</p>

<ol>
<li><p>Let <var>registry</var> be a new <code>CustomElementRegistry</code> object.
<li><p>Return <var>registry</var>.
</ol>

<p><dfn>Element definition</dfn> is a process of adding a <span>custom element definition</span>
to the <code>CustomElementRegistry</code>. This is accomplished by the <code
to the <code>CustomElementRegistry</code> object. This is accomplished by the <code
data-x="dom-CustomElementRegistry-define">define()</code> method. <span w-nodev>When invoked,
the <dfn><code data-x="dom-CustomElementRegistry-define">define(<var>name</var>,
<var>constructor</var>, <var>options</var>)</code></dfn> method must run these steps:</span></p>
Expand All @@ -66479,11 +66510,11 @@ dictionary <dfn>ElementDefinitionOptions</dfn> {
<li><p>If <var>name</var> is not a <span>valid custom element name</span>, then throw a
<span>"<code>SyntaxError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If this <code>CustomElementRegistry</code> contains an entry with <span
<li><p>If this <code>CustomElementRegistry</code> object contains an entry with <span
data-x="concept-custom-element-definition-name">name</span> <var>name</var>, then throw a
<span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If this <code>CustomElementRegistry</code> contains an entry with <span
<li><p>If this <code>CustomElementRegistry</code> object contains an entry with <span
data-x="concept-custom-element-definition-constructor">constructor</span> <var>constructor</var>,
then throw a <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>

Expand All @@ -66508,11 +66539,12 @@ dictionary <dfn>ElementDefinitionOptions</dfn> {
</ol>
</li>

<li><p>If this <code>CustomElementRegistry</code>'s <span>element definition is running</span>
flag is set, then throw a <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If this <code>CustomElementRegistry</code>'s <span>element definition is
running</span> flag is set, then throw a <span>"<code>NotSupportedError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>Set this <code>CustomElementRegistry</code>'s <span>element definition is running</span>
flag.</p></li>
<li><p>Set this <code>CustomElementRegistry</code>'s <span>element definition is
running</span> flag.</p></li>

<li><p>Let <var>formAssociated</var> be false.</p></li>

Expand Down Expand Up @@ -66642,11 +66674,11 @@ dictionary <dfn>ElementDefinitionOptions</dfn> {
data-x="concept-custom-element-definition-disable-shadow">disable shadow</span>
<var>disableShadow</var>.</p></li>

<li><p>Add <var>definition</var> to this <code>CustomElementRegistry</code>.</p></li>
<li><p>Add <var>definition</var> to this <code>CustomElementRegistry</code> object.</p></li>

<li><p>Let <var>document</var> be this <code>CustomElementRegistry</code>'s <span>relevant global
object</span>'s <span data-x="concept-document-window">associated
<code>Document</code></span>.</p></li>
<li><p>Let <var>document</var> be this <code>CustomElementRegistry</code>'s <span>relevant
global object</span>'s associated <code data-x="DOM DocumentOrShadowRoot"
>DocumentOrShadowRoot</code>.</p></li>

<li><p>Let <var>upgrade candidates</var> be all elements that are <span data-x="shadow-including
descendant">shadow-including descendants</span> of <var>document</var>, whose namespace
Expand Down Expand Up @@ -66677,6 +66709,12 @@ dictionary <dfn>ElementDefinitionOptions</dfn> {
</li>
</ol>

<p class="note"><code data-x="dom-CustomElementRegistry-define">define</code> and the other
methods for <code>CustomElementRegistry</code> will operate on the definitions set for the
respective object such as the <code data-x="dom-window-customElements">customElements</code> or
other registries created with
<code data-x="dom-CustomElementRegistry">new CustomElementRegistry()</code>.</p>

<p>When invoked, the <dfn><code
data-x="dom-CustomElementRegistry-get">get(<var>name</var>)</code></dfn> method must run these
steps:</p>
Expand Down Expand Up @@ -125034,6 +125072,7 @@ INSERT INTERFACES HERE
Leif Halvard Silli,
Leif Kornstaedt,
Lenny Domnitser,
Leo Balter,
Leonard Rosenthol,
Leons Petrazickis,
Lobotom Dysmon,
Expand Down