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

> To me, "access" couldn't happen at either the layers or scope proximity step in the cascade. It must happen before, I assume in the context step, and would pass first through the element-attached styles (style attribute in cascade 6) step.

To clarify: 'Cascading' happens as a resolution step after 'filtering' is complete. That's my point, they are separate steps. While both layers and scope show up in the 'cascading' process, with an impact on declaration priority:

- The `@layer` syntax is _only_ a mechanism for managing cascade priority. That's all it does currently.
- The `@scope` syntax is a _selector mechanism_ primarily for managing access. It's primary function is 'filtering' before the cascade. But (like other selectors) it has some _heuristic implications_ on cascade priority.

One of them _is a filtering mechanism_ (with some cascade implications), and the other one _is a cascading mechanism_ (full stop). That was very intentional. Layers were designed specifically to provide a cascade mechanic that would not be entangled with filtering. The fact that `@scope` shows up in the cascade is the most controversial thing about it. Linking those two things is risky, as we've seen over the years managing selector specificity.

When it comes to filtering which styles are attached, there are two existing mechanisms that are more appropriate:

- If we're defining styles that apply to a specific context, that's `@scope`
- If we just want easy access to named chunks of CSS, we have `@sheet`

In both cases, layers have roughly the right shape for what we want - letting us divide and label parts of a CSS file. So we absolutely want ways to put sheets or scopes (or whatever) _into layers_. That would be similar to the way we can import entire CSS files into layers. And it would be useful for component authors to expose layers, for more nuanced cascading between page and shadow-dom. Layers do seem essential to the solution here – because we're concerned with both _which styles apply_, and also _how they cascade_.

While all of that makes it very tempting to use `@layer` syntax for the whole thing, I think that would be a mistake. `@layer` is _the only unencumbered cascade mechanic we have_, designed specifically to disentangle filtering from cascading – because otherwise it was impossible to control _cascade priority_ without also manipulating _selection_. Let's not make that mistake again. 

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

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

Received on Thursday, 21 March 2024 01:22:56 UTC