- From: Bruce B. Anderson <notifications@github.com>
- Date: Mon, 14 Oct 2019 09:18:43 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/846@github.com>
Related issues:
https://github.com/w3c/webcomponents/issues/154
https://github.com/w3c/webcomponents/issues/488
https://github.com/w3c/webcomponents/issues/842
https://github.com/w3c/webcomponents/issues/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:
```JavaScript
customElements.defineNS(namespace: string, name: string, constructor, options);
```
So for example:
```JavaScript
customElements.defineNS('https://unpkg.com/my-custom-element@0.0.47/my-custom-element.js', 'my-custom-element', MyCustomElement)
```
would register a (or another) version of MyCustomElement, which would be activated if using:
```JavaScript
const myCustEl = document.createElementNS('https://unpkg.com/my-cust-element@0.0.47/my-custom-element.js', 'my-custom-element');
container.appendChild(myCustEl);
```
or
```html
<ns:my-custom-element xmlns:ns="https://unpkg.com/my-cust-element@0.0.47/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
```html
<my-custom-element></my-custom-element>
```
as before. I.e. the first registration gets to claim the non name-spaced tag.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/846
Received on Monday, 14 October 2019 16:18:45 UTC