-
Notifications
You must be signed in to change notification settings - Fork 645
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-selectors] Why does :is()
have the specificity of the most specific selector in its arguments?
#3325
Comments
See #1027. The expansion into all possible combinations can grow exponentially, which is bad. |
The alternative would be taking the specificity of the least-specific selector in its arguments. But yeah, what @Loirooriol said. |
Closing out, please re-open if there's something to fix. |
While exponentially large Cartesian products can be problematic, the current spec also has drawbacks:
:is(.foo, #bar) {color: red;}
.foo {color: blue;} gives a red .foo {color: red;}
#bar {color: red;}
.foo {color: blue;} gives a blue one. (Expanding to multiple rulesets because This can be mitigated per sheet, but if the definitions are in distinct sheets it will bite people.
If instead you went for a Cartesian product approach, (maybe with an expansion limit for sanity), these three concerns would be addressed. Edit: also, since SASS has been using the Cartesian products for a decade for its nested selector, and is widely deployed in the real world, I think that this concern about explosion is merely theoretical. You get |
Hi @fantasai I thought this was a lost cause... Are there recent developments that made the WG reconsider this point? |
https://drafts.csswg.org/selectors-4/#matches
I believe it would make more sense if the specificity would be identical to that when the selector would be expanded into all possible combinations, which also makes polyfilling using PostCSS easier.
The text was updated successfully, but these errors were encountered: