Skip to content

Support :where pseudo class #579

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

Closed
jannispl opened this issue Sep 29, 2021 · 7 comments · Fixed by #582
Closed

Support :where pseudo class #579

jannispl opened this issue Sep 29, 2021 · 7 comments · Fixed by #582

Comments

@jannispl
Copy link
Contributor

Would it be sensible to implement support for the :where pseudo class selector?

https://developer.mozilla.org/en-US/docs/Web/CSS/:where

@fb55
Copy link
Owner

fb55 commented Sep 29, 2021

Happy to accept a PR for this! You'd have to add this to css-what in

https://github.com/fb55/css-what/blob/1e523da931338953c68cc6e0d7a1e98639aa62c9/src/parse.ts#L107-L114

fb55/css-what#288 should be a good example for a PR. Once it can be parsed, the new alias has to be added here:

is,
/**
* `:matches` is an alias for `:is`.
*/
matches: is,

Also please add a basic test cases to make sure we won't accidentally drop support for it.

@jannispl
Copy link
Contributor Author

Are you suggesting that :where should be implemented as an alias for :is/:matches? I am not entirely certain if this library has to respect specificity, which works differently for :where:

The difference between :where() and :is() is that :where() always has 0 specificity, whereas :is() takes on the specificity of the most specific selector in its arguments.

@fb55
Copy link
Owner

fb55 commented Sep 30, 2021

Yes, I am suggesting to just create an alias. Specificity is important for deciding which selectors have precedence for which element when applying styles. That is out of scope for this library (and can be implemented in a separate module if needed).

@kyubisation
Copy link

@fb55 Sorry to ask this; Would it be possible to create a release with this fix/feature?

@jeripeierSBB
Copy link

Critters is waiting for this fix too: GoogleChromeLabs/critters#90

@fb55
Copy link
Owner

fb55 commented Dec 14, 2021

Published as v4.2.0.

@kyubisation
Copy link

Thank you very much 😃

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

Successfully merging a pull request may close this issue.

4 participants