Registry
The registry is the only code that constructs an instance. It holds one entry per name and one controller per element/component pair.
Registering
registerComponent(Ctor)— one eager entry, and its declared familyregisterComponents(...ctors)— several at onceregisterManifest(entries)— lazy entries in the same map
Building a manifest
defineManifest(options)— derive tokens from module pathsfromMetaGlob(glob)— a Viteimport.meta.globresultfromWebpackContext(context)— a webpack context
Looking instances up
Four functions answer from the DOM. They keep no registry of instances.
| Function | Population |
|---|---|
getInstances() | every instance that exists, mounted or not |
getMountedInstances() | the live ones — safe to call a method on |
getUnmountedInstances() | built, then stood down |
getInstance(el, name) | the one on this element |
js
getMountedInstances('Dialog').forEach((dialog) => dialog.close());
getInstances('Dialog', section);
getUnmountedInstances('Dialog');
getInstance(el, 'Dialog');
getInstances(el);The three plural forms take the same two overloads: a name with an optional ParentNode root, or an element.
- A matching element with no instance is skipped, and that is the whole narrowing.
selectorFor(name)over-matches on purpose — it lists the responsive spellings ofdata-componenttoo — and the instance-map read removes an inactive declaration, because a breakpoint-withdrawn component is destroyed and deleted from the map. rootis aParentNodeand the call isquerySelectorAll, so an element root searches its descendants and never matches itself.- The element overload is the only form that reaches a detached element, since
querySelectorAll()does not see one. Pass the detached root asrootwhen a name lookup has to reach inside it. - There is no
getMountedInstance. The singular returns one object, so a caller reads.$isMountedon it.
In tests
resetRegistry() is re-exported from /test and drops every registration. It is not part of a page's vocabulary.
Read next
The registry explains the entry, the controller and the one scheduling algorithm that covers eager, lazy and conditional mounting.