From e0699796f01a92817c87121e8284c38ff8ed4a05 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Wed, 19 Aug 2020 15:34:52 -0700 Subject: [PATCH] Add Scoped Custom Elements Registries --- source | 63 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/source b/source index 2488e8f79bb..fa5be21b341 100644 --- a/source +++ b/source @@ -66390,6 +66390,8 @@ document.body.append(parent);
[Exposed=Window]
 interface CustomElementRegistry {
+  constructor();
+
   [CEReactions] undefined define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options = {});
   (CustomElementConstructor or undefined) get(DOMString name);
   Promise<CustomElementConstructor> whenDefined(DOMString name);
@@ -66428,7 +66430,6 @@ dictionary ElementDefinitionOptions {
    
Defines a new custom element, mapping the given name to the given constructor as an autonomous custom element.
-
window . customElements . define(name, constructor, { extends: baseLocalName })
@@ -66464,8 +66465,38 @@ dictionary ElementDefinitionOptions { connected. +

New instances of CustomElementRegistry can be defined and attached to a + ShadowRoot through the registry option from attachShadow(). Those instances are independent of the + instance available at window.customElements, as + the latter is attached to the + associated Document.

+ +
+
registry = new CustomElementRegistry()
+ +
Defines a new Registry that can map an + independent set of custom elements, which is + not associated yet to any ShadowRoot.
+ +
registry . define(name, + constructor)
+ +
Defines a new custom element within the given registry, + mapping the given name to the given constructor as an autonomous custom element. +
+
+ +

When the CustomElementRegistry() + constructor is invoked, the user agent must run the following steps:

+ +
    +
  1. Let registry be a new CustomElementRegistry object. +

  2. Return registry. +

+

Element definition is a process of adding a custom element definition - to the CustomElementRegistry. This is accomplished by the CustomElementRegistry object. This is accomplished by the define() method. When invoked, the define(name, constructor, options) method must run these steps:

@@ -66479,11 +66510,11 @@ dictionary ElementDefinitionOptions {
  • If name is not a valid custom element name, then throw a "SyntaxError" DOMException.

  • -
  • If this CustomElementRegistry contains an entry with

    If this CustomElementRegistry object contains an entry with name name, then throw a "NotSupportedError" DOMException.

  • -
  • If this CustomElementRegistry contains an entry with

    If this CustomElementRegistry object contains an entry with constructor constructor, then throw a "NotSupportedError" DOMException.

  • @@ -66508,11 +66539,12 @@ dictionary ElementDefinitionOptions { -
  • If this CustomElementRegistry's element definition is running - flag is set, then throw a "NotSupportedError" DOMException.

  • +
  • If this CustomElementRegistry's element definition is + running flag is set, then throw a "NotSupportedError" + DOMException.

  • -
  • Set this CustomElementRegistry's element definition is running - flag.

  • +
  • Set this CustomElementRegistry's element definition is + running flag.

  • Let formAssociated be false.

  • @@ -66642,11 +66674,11 @@ dictionary ElementDefinitionOptions { data-x="concept-custom-element-definition-disable-shadow">disable shadow disableShadow.

    -
  • Add definition to this CustomElementRegistry.

  • +
  • Add definition to this CustomElementRegistry object.

  • -
  • Let document be this CustomElementRegistry's relevant global - object's associated - Document.

  • +
  • Let document be this CustomElementRegistry's relevant + global object's associated DocumentOrShadowRoot.

  • Let upgrade candidates be all elements that are shadow-including descendants of document, whose namespace @@ -66677,6 +66709,12 @@ dictionary ElementDefinitionOptions {

  • +

    define and the other + methods for CustomElementRegistry will operate on the definitions set for the + respective object such as the customElements or + other registries created with + new CustomElementRegistry().

    +

    When invoked, the get(name) method must run these steps:

    @@ -125034,6 +125072,7 @@ INSERT INTERFACES HERE Leif Halvard Silli, Leif Kornstaedt, Lenny Domnitser, + Leo Balter, Leonard Rosenthol, Leons Petrazickis, Lobotom Dysmon,