-
Notifications
You must be signed in to change notification settings - Fork 391
Closed
Labels
Description
Following up on issue #431, I'd like to propose that window.customElements allow a dev to retrieve information about the custom elements which have been registered. It sounds like @domenic was supportive of this idea, so as a strawman, I propose adding the following:
window.customElements.get(name). Returns the class which was previously registered withdefine(name), orundefinedif no element has yet been registered with that name.window.customElements[@@iterator](). This returns a newIteratorobject that enumerates the[name, class]pairs registered. I don't particularly care in what order the entries are returned. For consistency withMap.prototype[@@iterator](), it would be nice to return these in the order in which they were defined.
This, at least would meet the needs I've encountered, chiefly being able to: 1) easily verify that a particular custom element has in fact been registered, 2) conditionally define an element if it hasn't already been registered. E.g.:
if (!window.customElements.get('my-element')) {
window.customElements.define('my-element', MyElement);
}
Reactions are currently unavailable