Re: [csswg-drafts] [css-conditional-4] Rename @when to @if (#6684)

@romainmenke wrote:

> _I am almost sure this must have been considered at some point and probably is not an option but after reading through (almost) all of this thread I did not see it mentioned directly._
> 
> Is it possible that sass `@if` can still be a superset of css `@if`?

That was [initially pointed out by me](https://github.com/w3c/csswg-drafts/issues/6684#issuecomment-1064630704) and [later picked up](https://github.com/w3c/csswg-drafts/issues/6684#issuecomment-1071723157) by @nex3 as one possible solution with some restrictions.

> Currently css `@if` conditionals with `media(...)` or `supports(...)` give parser errors.

That's incorrect. E.g. `@if media(screen)` _is_ valid in Sass as pointed out by @nex3's comment linked to above. See also [one of my previous posts](https://github.com/w3c/csswg-drafts/issues/6684#issuecomment-1069762588).

Having said that, there are no sites using the `media()` function in @rviscomi's data. That doesn't mean it's never used, though it can at least be seen as indicator that it is uncommon to use it.

Though [according to its documentation](https://sass-lang.com/documentation/syntax/structure#other-expressions) Sass allows any core library or user-defined function as expression within [`@if`](https://sass-lang.com/documentation/at-rules/control/if). So while pure function calls without variables seem to be very uncommon according to the provided data, the CSS and Sass syntaxes for the conditions currently _do_ clash.

This means that in order to let Sass' `@if` be a superset of CSS' `@if`, this possible clash needs to be avoided. And that again means to either change the syntax of CSS or Sass.

Sebastian

-- 
GitHub Notification of comment by SebastianZ
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6684#issuecomment-1076936412 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 24 March 2022 00:07:36 UTC