Re: [w3c/webcomponents] Why do we really need hyphens? (#658)

@Nektro 

> They already are [scoped] in the sense that custom elements are only available if you define them in your document.

Correct me if I'm wrong, but _a vast majority_ of web applications consist of a single document. That argument there is like trying to convince React team to force everyone to globally register all components by name, per document, which would result in a huge storm of frustrated developers.

We need scoping _inside a single application_, and because most applications consist of a single document, we need scoping inside of documents, and shadow roots are the obvious unit of encapsulation for that (for all other Web Component encapsulation).

> thus ensuring a tag you make today isn't going to conflict with an official element added later on.

That's not going to happen in shadow roots. Once a scoped name is defined in a shadow root, introducing a new native builtin will do absolutely nothing because the root's definition of the element will continue to be the same, because it shadows the outer scope.

This is the same in just about all programming languages.

@Jamesernator 

> even if a tag is part of the shadow DOM if behavior of the tag changes after the element has been filled then there's a period of standard DOM behavior.

The simple good practice of defining the element names before rendering the DOM content would be useful here. 

There's possible ways to solve it for everyone: Maybe overrides can only be defined before any such elements exist in the root, otherwise a _helpful_ error can be thrown, and the `define()` call fails. This will force people to design custom elements where all Elements that will be inside the shadow root are defined before ever being placed in the DOM.


-- 
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/658#issuecomment-365357451

Received on Tuesday, 13 February 2018 18:29:08 UTC