Skip to content

[css-mediaqueries-5] How to handle media query lists in @custom-media rules #5458

Closed
@stephen

Description

@stephen

In media queries level 5, custom media queries are allowed to specify a list.

As an example, how should this stylesheet get handled?

/* --modern targets modern devices that support color or hover */
@custom-media --modern (color), (hover);

@media (--modern) and (width > 1024px) {
  .a { color: green; }
}

My initial guess was that user agents should do a dot product of sorts and produce rules for @media (color) and (width > 1024px), (hover) and (width > 1024px) { ... }. This feels to me like a reasonable (albeit somewhat tricky to parse) interpretation of the stylesheet authors intent.

However, looking at the existing postcss-custom-media implementation, the produced media query is: @media (color), (hover) and (width > 1024px) { ... }. This at least felt surprising to me - it's not clear to me why you'd try to write a custom media query with multiple media queries in the list.

If this is the intended behavior, If It'd be helpful to hear if there is a compelling use case for this kind of direct interpolation.

If it's not an intended behavior, I wonder if it'd be clearer for stylesheet authors if @custom-media only allowed a single media query production rather than a list of media queries.


tl; dr: should @custom-media only take a single media query instead of a list?

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