liveBook · Manning

customElements

As explained in Vanilla Web

The browser global property that provides access to a CustomElementRegistry instance.

The browser’s `customElements` global provides access to a CustomElementRegistry. Use its helpers to check whether an element is registered, wait for its definition, or upgrade elements in a subtree. section 7.6.5

The registry’s helper methods support these tasks:

  • `get(name)` returns the registered constructor or `undefined`. section 7.6.5
  • `whenDefined(name)` returns a promise that resolves when the element is registered, allowing work to wait until a component is available. section 7.6.5
  • `upgrade(root)` upgrades registered custom elements in a subtree. It is rarely needed, but can help when markup is injected before registration. section 7.6.5

How Vanilla Web covers it

How deep it goes
Defines three helper methods and notes that subtree upgrades are rare, while deferring lazy-loading detail.
Examples
Uses `get(name)`, `whenDefined(name)`, and `upgrade(root)` as concrete method examples.
What you can do after
Apply the registry API to check registration, wait for a definition, or upgrade a subtree.
How it connects
Connects custom element registration with promises, deferred work, and lazy loading.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vanilla Web. The section links point to the parts of the book it draws on.