w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.35k stars 641 forks source link

[css-cascade-6] Can we support implicit scopes in nested settings? #10497

Open mirisuzanne opened 1 week ago

mirisuzanne commented 1 week ago

We have previously resolved to supply an 'implicit' scope-root inside <style>. The root is the parent node of the <style> element:

<article id="my-thing">
  <style>@scope { /* similar to `@scope (article#my-thing)` */ }</style>
</article>

A different implicit scope-root might be more useful when @scope is nested inside other selectors. In that case, I would expect the missing (<scope-start>) should default to (&):

article {
  /* un-scoped `article` declarations */

  @scope { /* same as `@scope (&)` */ }
  @scope to (.another-thing) { /* @scope (&) to (.another-thing) */ }
}

That isn't exactly a parallel behavior, and I'm not sure if there are edge cases where it might be unclear which is intended. But I think this would be the most useful/expected result from a nested @scope syntax.

andruud commented 1 week ago

I think it makes sense. But since it's a breaking change, we'd ideally have a use-counter before making a decision.

mirisuzanne commented 1 week ago

@andruud could you start running that use-counter now, or should we get a resolution in advance? It seems like there's positive interest in this, and it would be worth taking to the group if we can.