Element Upgrades
Web Components โฉ Custom Elements โฉ
<time-formatted> - example
Custom elements can be used before their definition is registered.
The process of calling customElements.define() and endowing an existing element with a class definition is called "element upgrades". ๐ Google โฉ Element Upgrades
If browser encounters <custom-element> before customElements.define(), the element is yet unknown, just like any non-standard tag. Undefined elements can be styled with CSS selector:not(:defined)
.
When customElement.define() is called, they are โupgradedโ: a new instance of CustomElement is created for each, and connectedCallback
is called. They become :defined
.
๐ pseudo-class
.whenDefined()
To know when a tag name becomes defined, you can use customElements.whenDefined(). It returns a Promise that resolves when the element becomes defined.
Last updated