Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-nesting][selectors] Specificity of & {} #11235

Closed
Crissov opened this issue Nov 18, 2024 · 1 comment
Closed

[css-nesting][selectors] Specificity of & {} #11235

Crissov opened this issue Nov 18, 2024 · 1 comment

Comments

@Crissov
Copy link
Contributor

Crissov commented Nov 18, 2024

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?

@Loirooriol Loirooriol added selectors-4 Current Work css-nesting-1 Current Work labels Nov 18, 2024
@Crissov
Copy link
Contributor Author

Crissov commented Nov 18, 2024

dupe of #10287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants