fb55/css-select

Support :where pseudo class

Closed this issue · 7 comments

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

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

fb55 commented

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.

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 commented

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).

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

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

fb55 commented

Published as v4.2.0.

Thank you very much 😃