Skip to content

[mediaqueries] Consider @media supports() #9375

@zcorpan

Description

@zcorpan

See whatwg/html#7540 (comment) and following comments

@zcorpan

I think if we want supports() to apply to all media="" attributes, it should be part of MQ. But processing a media query list instead returns two booleans (supports result, MQ result), so that we can avoid fetching stylesheets where supports is false but do load them when supports is true (regardless of the MQ result).

This would make supports() consistently available (Link header, various HTML elements, @import, @media, constructable stylesheets options bag). Also makes the integration for HTML simpler, and less surgery needed in CSSOM. See w3c/csswg-drafts#9361

Maybe the supportsText for CSSImportRule wouldn't be needed anymore if it's part of the MediaList.

@emilio

@zcorpan what does that give you that renaming this to <style-sheet-condition> or so and referencing that everywhere doesn't?

With your proposal it feels rather weird to be able to do @media supports(), and you'd need to track the "supports" result across the whole condition tree, which is a bit odd. So we'd need to convert the media query evaluation to track not only true/false/unknown as it does now, but something like always-true/always-false/true/false/unknown.

To be clear, I think that's doable, but it's probably less straight-forward than the alternative?

@zcorpan

I guess my main concern is consistency for web developers about where supports() works, and how to expose it in the CSSOM. So maybe first we need to decide whether @media supports() should be a thing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions