Re: [csswg-drafts] [css-conditional] `@supports-condition`, for larger feature queries and named reuse (#12622)

The CSS Working Group just discussed ``[css-conditional] `@supports-condition`, for larger feature queries and named reuse``, and agreed to the following:

* `RESOLVED: Draft this into the same spec as @custom-media`
* `RESOLVED: Add Lea as editor of that spec`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> lea: We have a bunch of issues around "how do we express this thing in @supports"<br>
&lt;fantasai> lea: we're creating a parallel syntax to describe CSS syntax<br>
&lt;fantasai> lea: makes it difficult to design, and also confusing for authors who don't understand CSS syntax well<br>
&lt;fantasai> lea: e.g. authors don't understand difference between descriptor and property<br>
&lt;fantasai> lea: What if you could just stuff an entire block of stuff into a condition and ask if it's valid?<br>
&lt;fantasai> lea: ...<br>
&lt;TabAtkins> (thanks to anders, too, for css parsing being robust)<br>
&lt;fantasai> lea: CSS parsing is robust enough to handle all sorts of invalid things, so what if we had something like @supports-condition where you can stuff whatever you want<br>
&lt;fantasai> lea: could be a selector and rule, or properties, or any at-rule, and you would check if it's valid<br>
&lt;fantasai> lea: could even check at-rules inside at-rules<br>
&lt;fantasai> lea: avoids needing to invent a meta-syntax for everything<br>
&lt;fantasai> lea: and also gives us more complex feature queries<br>
&lt;fantasai> lea: parallel to custom-media<br>
&lt;fantasai> lea: also provide maintainability benefit<br>
&lt;fantasai> lea: we still need special functions for things that don't cause a parse error but need to check support<br>
&lt;fantasai> lea: Even at-rule() could have simple version for does this at-rule exist<br>
&lt;fantasai> lea: but for more complicated things, better to say the syntax you're testing<br>
&lt;fantasai> lea: some issue raised<br>
&lt;fantasai> lea: but seems reasonable you might want to combine named feature queries with inline feature queries<br>
&lt;fantasai> lea: also, should be able to name inline queries<br>
&lt;fantasai> lea: so rule could have block syntax and non-block syntax<br>
&lt;fantasai> lea: also question of how do you combine named feature queries with inline queries to create higher-level queries<br>
&lt;fantasai> lea: maybe useful for v2<br>
&lt;fantasai> lea: main issue is that condition token requries parens around condition<br>
&lt;fantasai> lea: so either have two syntaxes, e.g. @supports --named-condition { ...}<br>
&lt;fantasai> lea: or a parenthesized version<br>
&lt;kbabbitt> q+<br>
&lt;fantasai> lea: do we allow plain --ident syntax? or parenthesize?<br>
&lt;fantasai> lea: I think it's common to parenthesize only when need to group, not in advance<br>
&lt;fantasai> lea: kbabbitt: raised issues wrt at-import and supports conditions<br>
&lt;TabAtkins> q+<br>
&lt;fantasai> lea: maybe you defer loading until the name is defined<br>
&lt;fantasai> lea: multiple conditions with same name, last one wins<br>
&lt;fantasai> lea: question of ordering wrt @import<br>
&lt;fantasai> lea: but we should have a JS method also<br>
&lt;fantasai> lea: JS method could even give you more info<br>
&lt;astearns> ack kbabbitt<br>
&lt;fantasai> kbabbitt: I like the set of ideas presented here<br>
&lt;fantasai> kbabbitt: I have some reservations around the edge cases<br>
&lt;astearns> q+<br>
&lt;fantasai> kbabbitt: I do agree that we still want the simple at-rule method on @supports for simple cases if an at-rule is recognized at all<br>
&lt;fantasai> kbabbitt: useful for cases such as @starting-style where you don't want to bother setting up extra context<br>
&lt;fantasai> kbabbitt: for JS query, just have a method that accepts a fragment of CSS<br>
&lt;fantasai> kbabbitt: other interesting case that came up is MQ, where the parsing is forgiving for cases where particular media feature can be parsed successfully but not supported<br>
&lt;fantasai> kbabbitt: need some additional handling there<br>
&lt;lea> q?<br>
&lt;fantasai> kbabbitt: one other thing, in terms of dealing with supports conditions on import, what could happen if author adds supports condition later<br>
&lt;lea> q+<br>
&lt;fantasai> kbabbitt: doing it with media queries already<br>
&lt;fantasai> kbabbitt: maybe some weirdness there<br>
&lt;andruud> q+<br>
&lt;fantasai> kbabbitt: overall, I like it as a direction. I think it's simple and more extensible than adding functions for support<br>
&lt;SebastianZ> q+<br>
&lt;astearns> ack TabAtkins<br>
&lt;noamr> q+<br>
&lt;fantasai> TabAtkins: +1 to what kbabbitt said, good idea in general<br>
&lt;fantasai> TabAtkins: question about parsing context of stuff inside the rule<br>
&lt;fantasai> TabAtkins: proposal make sit as if you're inside an existing style rule, so immediately test for properties<br>
&lt;fantasai> TabAtkins: Need to be careful so that those things not allowed inside a style rule would work<br>
&lt;fantasai> TabAtkins: issues wrt cyclic resolved by earlier discussion about define-before-use<br>
&lt;matthieud> q+<br>
&lt;andruud> q-<br>
&lt;fantasai> TabAtkins: Final bit about using inside an @import, I think we should have the new custom whatevers to have a JS API so you can register them in JS<br>
&lt;fantasai> TabAtkins: and that can be globally available<br>
&lt;SebastianZ> +1 on kbabitt's points<br>
&lt;astearns> ack astearns<br>
&lt;fantasai> TabAtkins: treated as appearing before start of all styles<br>
&lt;fantasai> astearns: I like the idea, a bit skeptical of the promise that this will save us from inventing other syntaxes<br>
&lt;fantasai> astearns: places where we do parse things more liberally<br>
&lt;fantasai> astearns: I think we should have this, but I think we're going to keep adding microsyntaxes anyway<br>
&lt;fantasai> astearns: and this reminds me of conversations with miriam and she says "this is another mixin isn't it"<br>
&lt;fantasai> astearns: various ways to name a block of CSS, can we have a generic solution for all of them<br>
&lt;astearns> ack fantasai<br>
&lt;lea> scribe+<br>
&lt;lea> fantasai: For @import, we should allow declaring these conditions as well as custom media, before @import so they can be used for conditional imports<br>
&lt;lea> fantasai: we already allow this for layer order<br>
&lt;lea> fantasai: for exactly this reason, you need to be able to control the layering of the imports, so there's precedent<br>
&lt;lea> fantasai: wrt this the context opened up by the custom supports condition should be a top level context, if you want to be inside a style rule, be inside a style rule<br>
&lt;kbabbitt> +1 to it being a top-level context<br>
&lt;lea> fantasai: if you want to test declarations that's already easy for @supports<br>
&lt;kbabbitt> in fact, I'd go slightly stronger and say it should be "brand new stylesheet context" so various features of @import can be tested<br>
&lt;lea> fantasai: if we want to do inline @supports opening bracket should already get you in that context<br>
&lt;lea> kbabbitt +1<br>
&lt;noamr> q-<br>
&lt;fantasai> @supports ({ top-level context check thing }) { stuff }<br>
&lt;fantasai> equivalent to<br>
&lt;fantasai> @supports-condition --foo { top-level context check thing };<br>
&lt;emilio> q+<br>
&lt;astearns> ack lea<br>
&lt;fantasai> @supports --foo;<br>
&lt;fantasai> s/;/ { stuff }<br>
&lt;TabAtkins> (we avoided inlining rules into @supports before because it's just unreadable. nothing wrong with it parsing-wise, it's just kinda ridiculous to actually look at)<br>
&lt;fantasai> lea: I agree wrt supporting these declarations prior to @important<br>
&lt;kbabbitt> s/@important/@import/<br>
&lt;lea> s/ @important/ @import/<br>
&lt;fantasai> lea: for testing media query features that are parsed vs supported, same as font-tech(), still need microsyntax<br>
&lt;fantasai> lea: but not having to create a new one for everything is a gain.<br>
&lt;fantasai> lea: For Tab, I was going to say, I'd have least constrained context<br>
&lt;fantasai> lea: but suggested that should be most unconstrained existing context, i.e. start of new style sheet<br>
&lt;fantasai> lea: some things are less easy, e.g. declarations, but like fantasai said it's easy to do already<br>
&lt;fantasai> lea: consistency of using existing well-defined context outweighs being able to nest raw declaraitons<br>
&lt;fantasai> lea: Alan said we'll still need functions that parallel syntax, I don't see why except as shortcuts<br>
&lt;fantasai> lea: we don't even need a descriptor arguemnt for at-rule, just test the at-rule<br>
&lt;fantasai> lea: it cuts down scope very much for these functions, even when a convenience<br>
&lt;fantasai> lea: so I do think we should try to make sure verything we want to test for can be done<br>
&lt;fantasai> lea: it is interesting idea to combine with mixins, but some things aren't allowed in mixins<br>
&lt;fantasai> lea: and here everything is allowed<br>
&lt;TabAtkins> +1, this reduces the value of new testing functions from "we need this to make it testable at all" to just "this will be a common test and it's inconvenient to write out fully"<br>
&lt;fantasai> fantasai: yea, I think they have to be separate. Mixins take argument,s bunch of other stuff<br>
&lt;astearns> q?<br>
&lt;noamr> q+<br>
&lt;astearns> ack SebastianZ<br>
&lt;fantasai> TabAtkins, depends how you format your source code really<br>
&lt;fantasai> SebastianZ: I think this should be specced and implemented ASAP<br>
&lt;fantasai> SebastianZ: we added at-rule() in 2022 and still not in a spec!<br>
&lt;fantasai> SebastianZ: in the meantime many ne at-rules which can't be tested for<br>
&lt;fantasai> SebastianZ: I'm totally for this @supports condition<br>
&lt;astearns> ack matthieud<br>
&lt;fantasai> matthieud: right now, @supports selector() doesn't take context into account<br>
&lt;fantasai> matthieud: e.g. relative selector won't check out<br>
&lt;TabAtkins> (I fell really behind around the end of my full-WFH isolation, sorry about that.)<br>
&lt;emilio> q-<br>
&lt;astearns> ack noamr<br>
&lt;fantasai> noamr: Maybe this could be an extension of custom-media, rather than another thing<br>
&lt;fantasai> noamr: idk if this is too much, but feels like we're having a lot of tidbits of names that are used in the same name<br>
&lt;fantasai> noamr: that'll simplify things<br>
&lt;lea> q?<br>
&lt;fantasai> noamr: custom-media is just an at-rule with a semicolon, not complicated<br>
&lt;astearns> ack fantasai<br>
&lt;lea> fantasai: at supports conditions and @media are doing largely the same thing, declaring a name for a condition, and should be more consistent<br>
&lt;lea> q+<br>
&lt;astearns> ack lea<br>
&lt;fantasai> s/at supports/@supports-condition/<br>
&lt;fantasai> s/@media/@custom-media<br>
&lt;TabAtkins> They should be `@custom-supports`. Unless we can finally agree on `@when` and make them mergeable...<br>
&lt;fantasai> lea: Value in harmonizing, but my understanding of @custom-media is defining an alias over what you can do in media<br>
&lt;fantasai> lea: whereas this allows new stuff<br>
&lt;SebastianZ> +1 on TabAtkins<br>
&lt;fantasai> fantasai: I was suggesting to be able to do it inline also<br>
&lt;fantasai> lea: Seems awkward. As long as it's not the only way.<br>
&lt;fantasai> TabAtkins: Until we have merged conditional, I think they should be separate at-rules<br>
&lt;fantasai> fantasai: They should at least have similar naming pattern<br>
&lt;fantasai> TabAtkins: yes, @custom-supports<br>
&lt;fantasai> lea: or @media-condition<br>
&lt;TabAtkins> fantasai: I like media-condition and supports-condition<br>
&lt;lea> or @media-query and @supports-query<br>
&lt;fantasai> astearns: Lots of feedback and enthusiasm, seems like we should work on it<br>
&lt;fantasai> lea: Draft into next level of conditoinal?<br>
&lt;fantasai> astearns: Add it to a new diff spec? Happy to take that resolution, or put it off if ppl wnat more details before a draft<br>
&lt;fantasai> fantasai: seems ready for a draft<br>
&lt;fantasai> lea: Shoudl be in the same spec as @custom-media<br>
&lt;fantasai> fantasai: yes<br>
&lt;lea> other naming idea: @supports-test @media-test<br>
&lt;fantasai> RESOLVED: Draft this into the same spec as @custom-media<br>
&lt;fantasai> RESOLVED: Add Lea as editor of that spec<br>
&lt;TabAtkins> scribe+<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12622#issuecomment-3204959140 using your GitHub account


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

Received on Wednesday, 20 August 2025 09:02:23 UTC