Definition
To define custom element use define
function. It takes a tag name and plain object with property descriptors, or an object with a map of definitions.
To simplify using external custom elements with those created by the library, you can pass constructor
instead of a plain object. Then define
works exactly the same as the customElements.define()
method.
Single Element
arguments:
tagName
- a custom element tag name ornull
,descriptorsOrConstructor
- an object with a map of hybrid property descriptors or a constructor
returns:
Wrapper
- custom element constructor (extendsHTMLElement
)
If the tagName
is set to null
, the define
function only generates a class constructor without registering it in the global custom elements registry. This mode might be helpful for creating a custom element for external usage without dependency on tag name, and where the hybrids
library is not used directly.
Map of Elements
arguments:
tagName
- a custom element tag name in pascal case or camel case,descriptorsOrConstructor
- an object with a map of hybrid property descriptors or constructor
returns:
{ tagName: Wrapper, ...}
- a map of custom element constructors (extendsHTMLElement
)
Last updated