Re: [WICG/webcomponents] "open-stylable" Shadow Roots (#909)

Here are some more reasons I like adding `/shadow/` as a piece of this [puzzle](https://github.com/WICG/webcomponents/issues/909#issuecomment-1936757672):
1. It's opt-in, new, and its easily _controllable_. This preserves existing behavior that gives shadowRoot authors control, but authors can choose to provide sufficient access to outer page scope(s) if desired.
3. It existed previously and was valuable. It was removed not because people didn't like/use it, but because implementors objected to its performance characteristics (but iirc this was largely based on its coupling with `/deep/`).
4. It's a regular CSS combinator. Although its behavior is new, combinators are well-trodden ground for the CSS spec, implementors, and users.
5. It could be extended/customized. Since its application would be controllable (via shadow root settings and/or something like `appearance`), how its applied could also be controllable. For example, there could be a mode where only `parts` were targetable, but importantly, as a pseudo-tree (e.g. match b inside a: `part(a) part(b)`).
6. When paired with the `rulesets` [idea](https://github.com/WICG/webcomponents/issues/909#issuecomment-1936757672) the _new_ syntax isn't overly cumbersome because it's easy to expose a given shadow tree to a rich set of selectors. It's only when a selector needs to match *across* scopes that `/shadow/` is needed. Since this is a less common case this seems fine and potentially even good since it's very explicit.
7. It's a little scary and this matches the spirit of [Chris' "I Know What I’m Doing" idea](https://frontendmasters.com/blog/a-modest-web-components-styling-proposal-an-i-know-what-im-doing-selector/) and is a **sufficient** _sign post_. Other APIs (e.g. React's [dangerouslySetInnerHTML](https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html)) have shown this type of approach can be valuable.
8. Encapsulation _is_ a critical part of Shadow DOM, _but_ it's easy to put too much emphasis on this. For example,  `"mode": "closed"` was considered so important that no consensus on a default could be reached and thus `"mode"` must always be specified. That said, I think it's fair to say that "open" is much more widely used today and this works in practice because of the previous point: `.shadowRoot` is a sufficient  _sign post_.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/909#issuecomment-1937020733
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/909/1937020733@github.com>

Received on Saturday, 10 February 2024 14:30:29 UTC