-
Notifications
You must be signed in to change notification settings - Fork 682
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
[mediaqueries] Consider @media supports()
#9375
Comments
This proposal duplicates the existing functions of the language, and such an illogical mixture of syntax is harmful to the future. To mix the logic on media and support, there is https://drafts.csswg.org/css-conditional/#when-rule. For conditional import from documents, there is https://drafts.csswg.org/css-cascade/#at-import. The web platform provides the corresponding tools on the CSS side. Responsibility for insufficient parity in HTML lies with the WHATWG. |
Also important to take any future conditions into account. So |
For HTML we're reconsidering whether to use |
Not quite. The To summarize the two options being discussed: in both cases,
I think either option is a fairly reasonable tradeoff, depending what we want to prioritize. Option 1 gives us better legacy support. Option 2 is a cleaner syntax, but less useful in the short-term. Looking ahead 5 years, I think the WHATWG is probably right that we don't need to overthink the transition period. Let's go with the cleaner separation of new attributes (option 2). The polyfill would be light-weight and temporary. |
I’d rather see option 1 land, as with 2 we’ll have the same problem again whenever some new condition gets introduced. Say – for some weird reason – a Taking a step back, you could say the following, since they’re all conditions:
Say there wasn’t any way yet to apply these conditions via HTML yet, I’d come up with a condition="supports(…) prefers(…)"
condition="media(…)"
condition="dayofweek(…)" 🤪 Lacking such an attribute today, we could reuse media="supports(…) prefers(…)"
media="media(…)" And yes, |
I would be ok with adding a I don't think extending the |
My suggestion is to make them aliases for a while and then eventually deprecate This aliasing is to cater for the time period in which browsers that don't understand Admittedly, a little of JS like Miriam suggested could plug this. UPDATE: I see what you’re aiming at though: keep |
That approach makes sense to me. To clarify: media queries would be allowed in both the existing |
The CSS Working Group just discussed
The full IRC log of that discussion<TabAtkins> bramus: For @import we have a bunch of conditions we can tag onto it, MQs and supports()<TabAtkins> bramus: You can use @supprots in your stylesheet, but we wanted a way to add it into <link rel=stylesheet> <TabAtkins> bramus: Proposal's evolved a bit. Currently proposal is a `condition=""` attribute <TabAtkins> bramus: This new attribute is future proof; if we just add <link supports> then what about the next condition <miriam> q+ <TabAtkins> bramus: I was thinking the syntax would be `condition="supports(...) and media(...)"` <TabAtkins> bramus: You have the same problem as with any new attribute, browsers that dont' udnerstand the attr will ignore it and apply the stylesheet <TabAtkins> bramus: So followup, maybe `media=""` can accept these? And we can add `condition=""` as a synonym? <astearns> ack miriam <emilio> q+ <TabAtkins> miriam: some context, we discussed at TPAC in meeting with WHATWG <TabAtkins> miriam: We'd proposed extending `media=""` to accept all import conditions <TabAtkins> miriam: the WHATWG did not like that <TabAtkins> miriam: advantage of using `media` is that it would be backcompat, it already fails if it's got unknown stuff <TabAtkins> miriam: They'd prefer us to think about the future; it's only a small polyfill to work around this for now <TabAtkins> miriam: So new proposal is the new attribute. I think Bramus's idea of a new generic condition attribute is fine. <TabAtkins> miriam: No need to define what goes into it, it should match @import <TabAtkins> miriam: taking the <import-condition> syntax, which is already defined <astearns> ack emilio <TabAtkins> q+ <TabAtkins> emilio: I'm not totally opposed to new attr, but it feels like a much bigger endeavor <TabAtkins> emilio: media is used on more things, <meta>, <source>,e tc <TabAtkins> emilio: I guess we can figure out if all of those need condition or can be just media, but that feels weird <TabAtkins> emilio: We also need to figure out how media nad condition interact <TabAtkins> emilio: And iirc, media attribute ends up in CSSSTyleSheet.media in th OM <bramus> q+ <TabAtkins> emilio: So do we need to reflect condition into the stylesheet? Only if it's an MQ? <TabAtkins> emilio: Seems okay in theory but it's a lot more work <TabAtkins> emilio: than just reusing media <astearns> ack TabAtkins <miriam> q+ <fantasai> TabAtkins: I think that the 'condition' attribute is fine <fantasai> TabAtkins: agree that re-using <import-condition> is right <fantasai> TabAtkins: a) everything that takes media= should take condition= ; no reason to restrict <fantasai> TabAtkins: b) interaction between media= and condition= should be imo, in presence of condition= media= is ignored <bramus> CLEVER! <fantasai> TabAtkins: that helps with the polyfill, because you can put a guaranteed failing media condition in <fantasai> TabAtkins: c) for media query in stylesheet, don't think it's particularly needed. We can always add later if we feel it's necessary <astearns> ack bramus <emilio> wfm <TabAtkins> bramus: I think my concern is addressed by Tab's (b) <fantasai> bramus: my concern addressed by saying media= gets ignored <TabAtkins> bramus: But then why don't we just upgrade media= to accept import conditions? <TabAtkins> astearns: I can see the parsimony of just updating media= <TabAtkins> astearns: But we can take this as designing a well-rounded condition attribute without worrying about the cruft of media= <fantasai> TabAtkins: parsing of raw media query is pretty weird, because of media types <fantasai> TabAtkins: having new attribute with media() function helps <fantasai> TabAtkins: also addresses question of reflection into stylesheet <fantasai> TabAtkins: if in media= have to say how it reflects, but new attribute can just not <astearns> ack fantasai <TabAtkins> fantasai: disagree with TAb about media vs condition <TabAtkins> fantasai: Think both should apply when both specified <TabAtkins> fantasai: But think we can add a keyword to media that says "go look at condition=", which'll be invalid on downlevel clients <bramus> q+ <TabAtkins> fantasai: I think if someone wrote an MQ they shouldn't have to duplicate that into condition= <TabAtkins> fantasai: We've also had discussions about @layer <TabAtkins> fantasai: It's not a conditional, and it has to be reflected in the OM <TabAtkins> fantasai: So would this new condition attr take in things like that? <TabAtkins> fantasai: Or would that have to be an additional attribute? <TabAtkins> miriam: This would not take layer() <TabAtkins> miriam: Just the import conditions <TabAtkins> miriam: WHATWG was very open to new attributes for things like @layer <TabAtkins> miriam: We wanted to solve this first so you can add layer= *and* have a way to make it fail if layer wasn't supported <TabAtkins> miriam: This solves that, you can fail it with a support query <astearns> ack miriam <TabAtkins> miriam: That leads into my next , I agree with Elika on how media/condition should interact <dbaron> also +1 to fantasai's proposal on interaction <TabAtkins> miriam: Main consideration for emilio's q about putting this on more media= things <TabAtkins> miriam: If we define this as <import-condition>, which is defined around stylesheets, will this be an issue later? <TabAtkins> miriam: Like an import condition that makes sense for images, specifically? <TabAtkins> miriam: And is that even an issue? Or would you just ignore/fail on the other elements? <TabAtkins> TabAtkins: I think we'd just fail queries that didn't apply to that type of import, yeah <TabAtkins> miriam: Would we define these new kinds of queries in <import-condition>? <TabAtkins> TabAtkins: Maybe. Or we'd extract the grammar ot an independent spec and just ref it in @import. <astearns> ack bramus <TabAtkins> bramus: I'm less sure about media= and condition= both declared <TabAtkins> bramus: I see authors moving to using only condition= with media() <TabAtkins> bramus: So for migration/polyfill I lean toward Tab's idea, but I need to give it more thought <TabAtkins> astearns: I think we can open separate issue <TabAtkins> TabAtkins: Yeah, I don't feel strongly about this, but would like to discuss it a bit more. Do it off the call <TabAtkins> fantasai: I see authors probably still using media= just becuase it's shorter, why type more <TabAtkins> astearns: Do we ahve an issue about other elements using media=? Or should we just resolve it today? <TabAtkins> fantasai: Well we don't control HTML but can make a proposal. <TabAtkins> fantasai: Thinking about what would be a reasonable resolution... <TabAtkins> fantasai: Can resolve to explore condition= <TabAtkins> fantasai: Can definitely resolve to reject media=supports() <TabAtkins> astearns: Proposed is we solve the use-cases with a new condition= attribute that takes <import-condition> syntax <fantasai> also @media supports(), which is the title of the issue <fantasai> 100% not accepted <TabAtkins> astearns: Any objections? <TabAtkins> RESOLVED: add a new condition= attribute that takes <import-condition> syntax <TabAtkins> TabAtkins: should we resolve to reject @media supports()? <TabAtkins> astearns: yeah. objections? <TabAtkins> RESOLVED: Do not add `supports()` to @media. |
I tagged this as closed accepted by resolution. I'm not sure there's anything left to do here on the CSS side. We may also be able to close the issue? This is a signal of CSSWG support for a particular resolution of whatwg/html#7540 The secondary discussion topic that came up is how should |
I’m not sure, but would |
I like that. I think name is also open to bikeshedding - but probably best to discuss that in the WHATWG issue as well. They will have to make the final call on that. |
Okay, I copied the comment there. |
Thanks all. I think we can close this issue with the resolution
What to do when both are specified was discussed in the HTML issue iirc (failed condition means don't load, no-match media means load but don't apply). |
See whatwg/html#7540 (comment) and following comments
@zcorpan
@emilio
@zcorpan
The text was updated successfully, but these errors were encountered: