[csswg-drafts] [css-nesting-1][css-cascade-6] Clarify absolutization of the selectors of `@scope` and nested style rules (#11212)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-nesting-1][css-cascade-6] Clarify absolutization of the selectors of `@scope` and nested style rules ==
For nested style rules, the [spec](https://drafts.csswg.org/css-nesting-1/#cssom) says:

  > When serializing a relative selector in a nested style rule, the selector must be absolutized, with the implied nesting selector inserted.

The related [commit](https://github.com/w3c/csswg-drafts/commit/4810428e9632d6f320498b53dcc428f187fc2c06) message refers to #8940, which seems unrelated. If I am not mistaken, it has to do with the implied specificity (#9069). Whether I am wrong or not, it might be helpful to explain the reason of the absolutization.

WPT covers this requirement in this [test](https://github.com/web-platform-tests/wpt/blob/107c5fc03139b3247920a0f40983bd1fe4d1fac2/css/css-cascade/at-scope-relative-syntax.html) (non-exhaustive), which is interesting because it shows that `:scope` is not absolutized. As noted in #9621, in which it was suggested to absolutize it, it would change the specificity. But this issue is still open.

Chrome also absolutizes a scoping root selector when `@scope` is nested in a style rule. I cannot find where this is specified, nor a corresponding test on WPT. And it does not absolutize a scoping limit selector.

```js
const sheet = new CSSStyleSheet
sheet.replaceSync('style { @scope (root) to (limit) {} }')
sheet.cssRules[0].cssText; // style { @scope (& root) to (limit) {} }
```

This somewhat suggests that `<scope-start>` produces `<relative-selector-list>`, at least when nested in a style rule. Should it?

Another question that comes to my mind is whether `nested {}` in `style { @scope { nested {} } }` is a nested style rule, a scoped style rule, or both. I think it is both, but `:scope` should still be implied (rather than `&`), as with any scoped style rule. Again, whether I am not wrong or not, I think it should be clarified.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11212 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 14 November 2024 10:43:19 UTC