w3c/csswg-drafts

[css-nesting][selectors] Specificity of `& {}`

Closed this issue · 1 comments

https://drafts.csswg.org/css-nesting/#nest-selector
https://drafts.csswg.org/selectors/#specificity

When used in any other context, [&] represents the same elements as :scope in that context (unless otherwise defined).

The nesting selector can be desugared by replacing it with the parent style rule’s selector, wrapped in an :is() selector.

This means that & {} can be desugared into :is(:scope) {} or :scope {}.

The specificity of the nesting selector is equal to the largest specificity among the complex selectors in the parent style rule’s selector list (identical to the behavior of :is()), or zero if no such selector list exists.

:is(:scope) {} or :scope {} would have specificity (0,1,0), but & {} is explicitly defined as having a specificity of (0,0,0) because there is no parent style rule’s selector list.

Since there is a collapsed explanation for the equivalency with :is() but there is no reasoning provided for this difference, is this truly intentional?

dupe of #10287