When called, the register method must run these steps:
ENVIRONMENT, the unit of related similar-origin browsing contextsDOCUMENT, the context object of the methodNAME, the custom element name of the element being registeredFUNCTION, the custom element constructor function, optional
- The
FUNCTIONis mutated to have a new@@createfunction that creates a new Element object.
- If
NAMEis an invalid custom element name, throw an InvalidCharacterError and stop. - Let
NAMESPACEbe HTML Namespace - Let
TYPEbeNAME - If
FUNCTIONis null: 1. LetFUNCTIONbe the result of calling FunctionAllocate withHTMLElementas the functionPrototype and true as strict. 2. LetPROTOTYPEbe the result of calling ObjectCreate withHTMLElement.prototypeas the proto. 3. Call DefinePropertyOrThrow(PROTOTYPE, "constructor", PropertyDescriptor{[[Value]]:FUNCTION, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false}). 4. Call DefinePropertyOrThrow(FUNCTION, "prototype", PropertyDescriptor{[[Value]]:PROTOTYPE, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false}). - Otherwise:
1. If
FUNCTIONandDOCUMENTare from different browsing contexts, throw aNotSupportedErrorand stop. 2. LetINTERFACEbeFUNCTION's interface 3. IfINTERFACEinherits fromSVGElement, setNAMESPACEto SVG Namespace 4. Otherwise, ifINTERFACEdoes not inherit fromHTMLElement, throw aNamespaceErrorand stop. 5. LetBASEbeINTERFACE's inherited interface that is nearest toBASEin the prototype chain and that is an element interface 6. IfBASEis notHTMLElementorSVGElement, letNAMEbe the local name, associated withBASEelement interface 7. LetPROTOTYPEbe the result of Get(FUNCTION, "prototype"). - If
DOCUMENTis an HTML document, convert bothNAMEandTYPEto lowercase - If there already exists a definition with the same
TYPE, throw aNotSupportedErrorand stop. - Let
LIFECYCLEbe lifecycle callbacks - Transfer callback named
readytoLIFECYCLEfrom property namedreadyCallbackonPROTOTYPE - Transfer callback named
insertedtoLIFECYCLEfrom property namedinsertedCallbackonPROTOTYPE - Transfer callback named
removedtoLIFECYCLEfrom property namedremovedCallbackonPROTOTYPE - Let
DEFINITIONbe the set of (TYPE,NAME,NAMESPACE,FUNCTION,LIFECYCLE) - Register the
DEFINITIONwithDOCUMENT - Run element upgrade algorithm with
DOCUMENT's browsing context andDEFINITIONas arguments - Invoke lifecycle callbacks with
ENVIRONMENTas argument - Return result of running custom element constructor generation algorithm with
FUNCTIONas argument.
FUNCTION, the custom element constructor function.
- The
FUNCTIONis mutated to have a new@@createfunction that creates a new Element object.
- If
FUNCTIONis already an interface constructor object for any interface object throw aTypeErrorand stop. - Let
DEFINITIONbe an element definition that hasFUNCTIONas custom element prototype - Let
CREATEbe a function which when called executes the following steps: 1. LetTYPEbe the custom element name inDEFINITION2. LetNAMEbe the local name inDEFINITION3. LetNAMESPACEbe the namespace inDEFINITION4. LetELEMENTbe the context object 5. SetELEMENT's local name toNAME, namespace to theNAMESPACE, and node document to the document with whichDEFINITIONis registered 6. IfTYPEis not the same asNAME, set the value ofELEMENT's is attribute toTYPE7. Run the element initialization algorithm withELEMENTas argument 8. ReturnELEMENT. - Call DefinePropertyOrThrow(
FUNCTION,@@create, PropertyDescriptor{[[Value]]:CREATE, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false}).