Re: [w3c/webcomponents] [idea] Allow custom element naming on a per-shadow-root basis. (#488)

> Anyways, I'm just simply asking you what you think the honest feasibility of implementing a shadow-root-scoped element naming concept is.

I don't have enough background to understand platform constrains so whatever I think/say might be irrelevant or wrong but I see the following issues:

  * if you `document.createElement('some-component')` which one is it?
  * if you have an element in a shadow root and you clone/import it somewhere where there is another definition, which one will win?
  * are elements upgraded multiple times if these travels around the DOM outside their shadow root?

What I see is that `x-gallery` should be a well known element in the page that behaves in an expected way. I want to be able to read its name, check the resgistry, verify its class, know its observed properties and know which event it exposes ... otherwise it'll be full chaos if I don't know what the hell is that `x-gallery`.

There are also way to avoid conflicts, you register elements only if not registered yet.
```js
if (!customElements.get('x-gallery'))
  customElements.define('x-gallery', class extends HTMLElement {});
```

>From components that behaves accordingly to their trusted `x-gallery` they should also do similar dance:
```js
customElements.whenDefined('x-gallery').then(() => {
  const XGallery = customElements.get('x-gallery');
  if (XGallery.brand === 'MyFavorite')
    customElements.define('x-gallery-card', class extends HTMLElement {});
});
```

And so on, so you have CE that trust each other and work as expected instead of having to deal with unpredictable components that might collide with each other.

And I am talking about a silly gallery, I can't imagine a `<paypal-credit-card>` provided by anyone byt `paypal` what could cause on a page.

TL;DR I think technically it could be done but the list of caveats and footguns would be longer than a list of benefits which are, IMO, rather confusing to me.

GO and ask A-Frame developers how happy they'd be to have anyone offering different A-Frame components ... I mean, come on, we all can namespace and namespace for developers have always been a plus in trust, rarely an issue.




-- 
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/488#issuecomment-341861627

Received on Saturday, 4 November 2017 01:18:44 UTC