Re: [csswg-drafts] [mediaqueries] Consider `@media supports()` (#9375)

> At this time scope() is also accepted to be added as an import condition.

Not quite. The `scope()` feature is planned as an addition to CSS imports alongside `layer()`, but they are not part of the '[import-condition](https://drafts.csswg.org/css-cascade-5/#typedef-import-conditions)' production. Scope and layer don't determine _if_ the style sheet should be applied, but rather _how_ it is applied.

---

To summarize the two options being discussed: in both cases, `layer` and `scope` and other import modifiers can be added to HTML as new attributes. The issue then is giving authors a way to add support-conditions while those new attributes are poorly supported. For that, we need a way to define support queries in HTML.

1. If we want these support conditions to work on browsers that pre-date the new syntax, then we need to build on an existing conditional attribute. We've discussed `rel` and `type`, but `media` seems to me like a clear winner. It might not be the ideal name for the thing, but it's also not an arbitrary mix of features – we would be defining the 'media' attribute to use the CSS 'import-condition' syntax. It's a syntax production that already exists in a well-defined space, and it already combines both media and support. But that's a tradeoff. How much do we care about failing the import in legacy browsers?
2. Alternately, we can decide (as the WHATWG suggests) that the legacy support issue is temporary, and in the long term we would prefer to have distinct attributes for each type of import condition. The `media` attribute continues to be media-specific, and we add a `supports` attribute. For now, authors will need to polyfill that supports attribute, but that's entirely possible with a little bit of JS, but down the road we get a more clear syntax.

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.

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


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

Received on Tuesday, 24 October 2023 17:23:13 UTC