From 32ecc9ecb42e1a0b7cb42241ddbc2c6b8eecb6b9 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 21 Apr 2023 12:27:17 +0100 Subject: [PATCH 1/8] Add customElements.getName(constructor) In CustomElements v0 you could use the `.name` field to get the defined tag name, but CustomElements v1 does not offer such a field. `localName` can be used within an instance but this prohibits use in, for example, static methods. This was discussed in the WCCG F2F, tracked in https://github.com/WICG/webcomponents/issues/566. The conclusion of the F2F was to write up a spec change and WPT tests. --- source | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source b/source index 295577fcfa1..bfbaee85e90 100644 --- a/source +++ b/source @@ -70569,6 +70569,7 @@ document.body.append(parent); interface CustomElementRegistry { [CEReactions] undefined define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options = {}); (CustomElementConstructor or undefined) get(DOMString name); + (DOMString or undefined) getName(CustomElementConstructor constructor); Promise<CustomElementConstructor> whenDefined(DOMString name); [CEReactions] undefined upgrade(Node root); }; @@ -70619,6 +70620,11 @@ dictionary ElementDefinitionOptions {
Retrieves the custom element constructor defined for the given name. Returns undefined if there is no custom element definition with the given name.
+
window.customElements.getName(constructor)
+ +
Retrieves the given name for a custom element defined for the given constructor. Returns undefined if there is no + custom element definition with the given constructor.
+
window.customElements.whenDefined(name)
Returns a promise that will be fulfilled with the custom element's constructor @@ -70858,6 +70864,18 @@ dictionary ElementDefinitionOptions {
  • Otherwise, return undefined.

  • +

    When invoked, the getName(constructor) method must run these + steps:

    + +
      +
    1. If this CustomElementRegistry contains an entry with constructor constructor, then return that + entry's name.

    2. + +
    3. Otherwise, return undefined.

    4. +
    +

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

    @@ -134363,6 +134381,7 @@ INSERT INTERFACES HERE 葛依寧 (Kat Hackett), Kathy Walton, 河童エクマ(Kawarabe Ecma) + Keith Cirkel, Keith Rollin, Keith Yeung, Kelly Ford, From e47ea446030dc8e250d6830e16d016568badcd14 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 24 Apr 2023 10:14:26 +0100 Subject: [PATCH 2/8] use nullish DOMstring --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index bfbaee85e90..1c3a4457869 100644 --- a/source +++ b/source @@ -70569,7 +70569,7 @@ document.body.append(parent); interface CustomElementRegistry { [CEReactions] undefined define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options = {}); (CustomElementConstructor or undefined) get(DOMString name); - (DOMString or undefined) getName(CustomElementConstructor constructor); + (DOMString?) getName(CustomElementConstructor constructor); Promise<CustomElementConstructor> whenDefined(DOMString name); [CEReactions] undefined upgrade(Node root); }; @@ -70873,7 +70873,7 @@ dictionary ElementDefinitionOptions { data-x="concept-custom-element-definition-constructor">constructor constructor, then return that entry's name.

    -
  • Otherwise, return undefined.

  • +
  • Otherwise, return null.

  • When invoked, the Date: Mon, 24 Apr 2023 10:37:36 +0100 Subject: [PATCH 3/8] fixup bad ref --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 1c3a4457869..635ad2b964e 100644 --- a/source +++ b/source @@ -70569,7 +70569,7 @@ document.body.append(parent); interface CustomElementRegistry { [CEReactions] undefined define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options = {}); (CustomElementConstructor or undefined) get(DOMString name); - (DOMString?) getName(CustomElementConstructor constructor); + (DOMString?) getName(CustomElementConstructor constructor); Promise<CustomElementConstructor> whenDefined(DOMString name); [CEReactions] undefined upgrade(Node root); }; From 28e1415d69f20d356e0d743501c5e4323f48bb77 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 24 Apr 2023 10:46:13 +0100 Subject: [PATCH 4/8] remove uneccessary parens --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 635ad2b964e..e3e08160359 100644 --- a/source +++ b/source @@ -70569,7 +70569,7 @@ document.body.append(parent); interface CustomElementRegistry { [CEReactions] undefined define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options = {}); (CustomElementConstructor or undefined) get(DOMString name); - (DOMString?) getName(CustomElementConstructor constructor); + DOMString? getName(CustomElementConstructor constructor); Promise<CustomElementConstructor> whenDefined(DOMString name); [CEReactions] undefined upgrade(Node root); }; From 88ee059f217d73637f8b36b3d919c1be514735f6 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 24 Apr 2023 10:47:22 +0100 Subject: [PATCH 5/8] fix null return --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index e3e08160359..9aa9795c831 100644 --- a/source +++ b/source @@ -70622,7 +70622,7 @@ dictionary ElementDefinitionOptions {

    window.customElements.getName(constructor)
    -
    Retrieves the given name for a custom element defined for the given constructor. Returns undefined if there is no +
    Retrieves the given name for a custom element defined for the given constructor. Returns null if there is no custom element definition with the given constructor.
    window.customElements.whenDefined(name)
    From 253e24a14bc3b41f80e14f5f895216270b8ffe60 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 24 Apr 2023 12:00:40 +0100 Subject: [PATCH 6/8] update phrasing --- source | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source b/source index 9aa9795c831..6c38f1ecc37 100644 --- a/source +++ b/source @@ -70864,16 +70864,15 @@ dictionary ElementDefinitionOptions {
  • Otherwise, return undefined.

  • -

    When invoked, the getName(constructor) method must run these - steps:

    +

    The getName(constructor) steps are:

    1. If this CustomElementRegistry contains an entry with constructor constructor, then return that entry's name.

    2. -
    3. Otherwise, return null.

    4. +
    5. Return null.

    When invoked, the Date: Mon, 24 Apr 2023 14:44:17 +0100 Subject: [PATCH 7/8] accidentally a word --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 6c38f1ecc37..afc4f3d159d 100644 --- a/source +++ b/source @@ -70865,7 +70865,7 @@ dictionary ElementDefinitionOptions {

    The getName(constructor) steps are:

    + data-x="dom-CustomElementRegistry-getName">getName(constructor) method steps are:

    1. If this CustomElementRegistry contains an entry with Date: Fri, 30 Jun 2023 14:57:57 +0200 Subject: [PATCH 8/8] Fix wrapping --- source | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source b/source index afc4f3d159d..ebf279c2a3a 100644 --- a/source +++ b/source @@ -70602,8 +70602,8 @@ dictionary ElementDefinitionOptions {

      window.customElements.define(name, constructor)
      -
      Defines a new custom element, mapping the given name to the given constructor as - an autonomous custom element.
      +
      Defines a new custom element, mapping the given name to the given constructor + as an autonomous custom element.
      window.customElements.define(name, constructor, @@ -70865,12 +70865,14 @@ dictionary ElementDefinitionOptions {

    The getName(constructor) method steps are:

    + data-x="dom-CustomElementRegistry-getName">getName(constructor)
    method + steps are:

    1. If this CustomElementRegistry contains an entry with constructor constructor, then return that - entry's name.

    2. + data-x="concept-custom-element-definition-constructor">constructor + constructor, then return that entry's name.

    3. Return null.