Re: [whatwg/dom] Declarative Shadow DOM (#510)

If you're creating a custom element, there's useful, convenient machinery for that which does lots of good things. This is not intended to help with custom elements in general; you already need JS for that, and there's very little we can add declaratively to help there.

This is for the simple cases of wanting to add a shadow DOM to an element for encapsulation purposes, in as light-weight a way as possible. There's a nice big bulleted list of reasons in the original post for why our current method of doing so is inconvenient and bad.  The gist of it is that the CSS encapsulation provided by shadow roots is *really good*, and we'd like to encourage its usage as much as possible to make sites more maintainable, but we don't want to require people to do a lot of JS work for something so simple.  (And beyond just "it's inconvenient", there are several other reasons why shoving this into JS is bad, listed in the OP.)

If you do happen to do `<custom-element><shadowroot>...</></>` in your page, we don't need to do anything special here - the parser will attach a shadow root to the element at the same time it would have otherwise appended light-dom children. I'm not familiar enough with the intricacies of the CE lifecycle to know if this is observable or not.  In any case, it's definitely not *intended* for this sort of usage; manually adding your shadow root to every CE instance is just doing a ton more work than is necessary.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/510#issuecomment-332017101

Received on Monday, 25 September 2017 21:21:48 UTC