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

> Would declarative shadow DOM be still a useful primitive when we have declarative custom elements? If so, why? What concrete use cases would it address better than declarative custom elements?

Definitely yes, I think. People have been asking for style isolation for *years*, and adding a shadow is the simplest way to do so with the existing primitives in the platform.  And style isolation is useful at a general "distinct parts of the page" level; requiring people to promote their element to a (single-use?) custom element to get this effect seems gratuitous. No matter how easy we make declarative custom elements, they'll always be additional steps and mental burden over just "put the contents of this element into a shadow for me", which is all you need and want for style isolation.

Avoiding additional unnecessary steps, even if they're objectively relatively simple, is the whole point of this entire exercise! A (complex) one-liner script that you copy-paste around is still, as we've seen, too much additional complexity for what people feel *should* be a simple operation.

> Are there benefits in having declarative shadow DOM in the browser beyond perf & not requiring scripts? If so, what are they? And what concrete use cases would that serve?

Ergonomics is the biggest thing.  If we want these things to be used by more authors, making them easy and simple to reach for, and more importantly, *natural* to reach for, rather than looking like an advanced hack for complicated use-cases only, is extremely important. An attribute or a wrapper element right at the point you want isolation to happen feels simple and more or less like normal HTML. A script that does some stuff and moves elements around does not.

-- 
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/831#issuecomment-598307771

Received on Thursday, 12 March 2020 17:13:51 UTC