diff --git a/source b/source index 54fc575d815..30da76e1e81 100644 --- a/source +++ b/source @@ -9731,6 +9731,26 @@ interface HTMLUnknownElement : HTMLElement { };
  • Let registry be the current global object's CustomElementsRegistry object.

  • +
  • +

    If NewTarget is equal to the active function object, then throw a + TypeError and abort these steps.

    + +
    +

    This can occur when a custom element is defined using an element interface as + its constructor:

    + +
    customElements.define("bad-1", HTMLButtonElement);
    +new HTMLButtonElement();          // (1)
    +document.createElement("bad-1");  // (2)
    + +

    In this case, during the execution of HTMLButtonElement (either explicitly, as + in (1), or implicitly, as in (2)), both the active function object and NewTarget + are HTMLButtonElement. If this check was not present, it would be possible to + create an instance of HTMLButtonElement whose local name was bad-1.

    +
    +
  • +
  • Let definition be the entry in registry with constructor equal to NewTarget. If @@ -9757,10 +9777,10 @@ interface HTMLUnknownElement : HTMLElement { };

    This can occur when a custom element is defined to not extend any local names, but inherits from a non-HTMLElement class:

    -
    customElements.define("bad-1", class Bad1 extends HTMLParagraphElement {});
    +
    customElements.define("bad-2", class Bad2 extends HTMLParagraphElement {});

    In this case, during the (implicit) super() call that occurs when - constructing an instance of Bad1, the active function + constructing an instance of Bad2, the active function object is HTMLParagraphElement, not HTMLElement.

  • @@ -9785,10 +9805,10 @@ interface HTMLUnknownElement : HTMLElement { };

    This can occur when a custom element is defined to extend a given local name but inherits from the wrong class:

    -
    customElements.define("bad-2", class Bad2 extends HTMLQuoteElement {}, { extends: "p" });
    +
    customElements.define("bad-3", class Bad3 extends HTMLQuoteElement {}, { extends: "p" });

    In this case, during the (implicit) super() call that occurs when - constructing an instance of Bad2, valid local names is the + constructing an instance of Bad3, valid local names is the list containing q and blockquote, but definition's local name is p, which is not in that list.

    @@ -66188,32 +66208,6 @@ dictionary ElementDefinitionOptions {
  • If IsConstructor(constructor) is false, then throw a TypeError and abort these steps.

  • -
  • -

    If constructor is either an interface object or named - constructor, whose corresponding interface either is HTMLElement or has - HTMLElement in its set of inherited interfaces, throw a - TypeError and abort these steps.

    - -
    -

    This prevents passing, for example, HTMLButtonElement as - constructor, and thus enabling the creation of HTMLButtonElement instances with a local name that is not button.

    - -

    Author-defined custom element constructors, - created for example via class extends HTMLElement {} or class extends HTMLButtonElement {}, will pass this step without throwing a - TypeError, since they are not interface - objects.

    - -

    Interface objects that do not inherit from - HTMLElement (for example TextTrack), or classes - defined in the JavaScript specification (such as Set), will pass this - step without throwing a TypeError. However, they will later cause create an - element to fail.

    -
    -
  • -
  • If name is not a valid custom element name, then throw a "SyntaxError" DOMException and abort these steps.