Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[idea] Support Namespaced Web Component Registration #846

Closed
bahrus opened this issue Oct 14, 2019 · 1 comment
Closed

[idea] Support Namespaced Web Component Registration #846

bahrus opened this issue Oct 14, 2019 · 1 comment

Comments

@bahrus
Copy link

bahrus commented Oct 14, 2019

Related issues:

#154

#488

#842

#716

This proposal doesn't necessarily contradict anything in the last one, the scoped custom registries proposal (I don't think).

I suspect something like this must have been considered, but just in case it is feasible:

I would like to avoid namespace collisions within the same shadow DOM scope, and to allow different versions of the same element name to run together, etc. It would use a new function, customElements.defineNS, with signature:

customElements.defineNS(namespace: string, name: string, constructor, options);

So for example:

customElements.defineNS('https://unpkg.com/[email protected]/my-custom-element.js', 'my-custom-element', MyCustomElement)

would register a (or another) version of MyCustomElement, which would be activated if using:

const myCustEl = document.createElementNS('https://unpkg.com/[email protected]/my-custom-element.js', 'my-custom-element');
container.appendChild(myCustEl);

or

<ns:my-custom-element xmlns:ns="https://unpkg.com/[email protected]/my-custom-element.js"></ns:my-custom-element>

If there is no global custom element already defined with name "my-custom-element", it would also register MyCustomElement in the global namespace where you could just use

<my-custom-element></my-custom-element>

as before. I.e. the first registration gets to claim the non name-spaced tag.

@rniwa
Copy link
Collaborator

rniwa commented Oct 14, 2019

This is a duplicate of the issue #634.

@rniwa rniwa closed this as completed Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants