Element.customElementRegistry is a read-only instance property that returns the CustomElementRegistry tied to an element, or null. Learn how scoped registries work with shadow DOM, why the value is fixed after creation, and how to feature-detect—with five examples and try-it labs.
01
Kind
Instance property
02
Access
Read-only
03
Returns
CustomElementRegistry | null
04
Set when
Element is created
05
Mutable?
No (once set)
06
Status
Limited availability
Fundamentals
Introduction
Most pages register custom elements on the global registry: window.customElements. Scoped custom element registries let a shadow tree (or other subtree) use its own registry so tag names do not collide with the rest of the page.
element.customElementRegistry tells you which registry that element will use when it is upgraded—or null if none was associated.
JavaScript
if ("customElementRegistry" in Element.prototype) {
console.log(el.customElementRegistry); // CustomElementRegistry or null
}
💡
Beginner tip
Think: which dictionary of custom tags does this element belong to? Global page, or a scoped registry inside a component?
Concept
Understanding the Property
MDN: the customElementRegistry read-only property of the Element interface returns the CustomElementRegistry object associated with this element, or null if one has not been set.
An element’s registry is set when the element is created (for example via Document.createElement() with a customElementRegistry option, or when parsed in a context that already has a scoped registry). Once set to a CustomElementRegistry, it cannot be changed. That registry decides which custom element definitions are used when the element is upgraded.
Read-only — you cannot reassign the property later.
Nullable — null means no registry was associated.
Scoped APIs — often used with new CustomElementRegistry() and shadow roots.
Limited availability — not Baseline; feature-detect always (MDN).
Foundation
📝 Syntax
JavaScript
customElementRegistry
Value
A CustomElementRegistry object, or null.
Item
Detail
Type
CustomElementRegistry | null
Access
Read-only
Global registry
window.customElements
Scoped registry
new CustomElementRegistry()
⚠️
Feature-detect first
Support for reading Element.customElementRegistry (and creating scoped registries) is still rolling out. Check "customElementRegistry" in Element.prototype before production use.
Pattern
📋 MDN Scoped Registry Example
MDN creates a scoped registry, attaches it to a shadow root, then confirms a child element reports the same registry:
Element.customElementRegistry has Limited availability on MDN (not Baseline). It is part of scoped custom element registries. Always feature-detect. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Limited availability
Element.customElementRegistry
Read-only CustomElementRegistry | null — which registry upgrades this element.
LimitedNot Baseline
Google Chrome146+
Yes
Microsoft Edge146+ (Chromium)
Yes
Mozilla Firefox150+ behind preference flag
Partial
Apple Safari26+
Yes
OperaFollow Chromium (scoped CE)
Yes
Internet ExplorerNot supported
No
customElementRegistryLimited
Bottom line: Use Element.customElementRegistry to inspect scoped registries. Feature-detect first. Prefer global window.customElements when scoped APIs are missing.
Wrap Up
Conclusion
customElementRegistry answers a focused Web Components question: which CustomElementRegistry owns this element? It is set at creation, stays fixed, and unlocks scoped registries in shadow trees—with Limited availability, so detect before you depend on it.
Pass customElementRegistry when attaching shadow roots
Compare with === to verify the expected registry
Null-check before calling registry methods
Keep a global-customElements fallback
❌ Don’t
Assign to customElementRegistry (read-only)
Assume every browser supports scoped registries
Expect scoped definitions to appear on window.customElements
Skip identity checks when debugging upgrades
Confuse this with registering via customElements.define alone
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about customElementRegistry
Read-only registry link—set at creation, used for scoped custom elements.
5
Core concepts
📄01
Get only
on Element
Kind
📝02
Registry
or null
Type
🔍03
Scoped CE
shadow trees
Use
✅04
Limited
not Baseline
Status
🎯05
Detect first
fallback ready
Tip
❓ Frequently Asked Questions
The CustomElementRegistry associated with the element, or null if none has been set.
No. MDN/BCD do not mark Element.customElementRegistry as Deprecated, Experimental, or Non-standard. It has Limited availability (not Baseline)—always feature-detect.
No. It is a read-only instance property. Once a CustomElementRegistry is set on the element, it cannot be changed.
When the element is created—for example Document.createElement() with a customElementRegistry option, or when the element is parsed inside a context that already uses a scoped registry (such as a shadow root).
window.customElements is the global registry. Element.customElementRegistry can point at that global registry or at a scoped CustomElementRegistry used only in a subtree (often a shadow tree).
So different components can define the same custom tag name without colliding in the global customElements registry.
Did you know?
Scoped registries exist so two libraries can both define <my-button> without fighting over the single global customElements map—each shadow tree can keep its own definitions.