- From: Lea Verou via GitHub <sysbot+gh@w3.org>
- Date: Sun, 23 Jun 2024 12:32:46 +0000
- To: public-css-archive@w3.org
> @LeaVerou Is there already a CSS function in existence or in the works that could be used to check whether or not the matched element matches a specified selector, essentially selector narrowing?
>
> For example…
>
> BEFORE AFTER
> ```css
> /* without using if() */
> .item {
> --symbol: "🩶";
> &::before {
> content: var(--symbol);
> }
> &.favorite {
> --symbol: "🧡";
> }
> }
> ```
>
> ```css
> /* using if() */
> .item {
> --symbol: if(matches(.favorite) ? "🧡" : "🩶");
> &::before {
> content: var(--symbol);
> }
> }
> ```
Possibly, but I think this warrants a new issue, as it’s introducing a new type of condition, and the whole point of the `if()` MVP is to reuse existing conditionals.
--
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10064#issuecomment-2184971117 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Sunday, 23 June 2024 12:32:47 UTC