Skip to content

[cssom-view] Different serialization across browsers for MediaQueryList #5588

@karlcow

Description

@karlcow

(Ooops I typed enter too fast)

This is triggered by mozilla-mobile/fenix#15124 (comment)

window.matchMedia('(max-width: 567px) and (max-aspect-ratio: 1/1)').media

Safari returns

"(max-aspect-ratio: 1/1) and (max-width: 567px)" = $1

Chrome returns

"(max-aspect-ratio: 1/1) and (max-width: 567px)"

Firefox returns

"(max-width: 567px) and (max-aspect-ratio: 1)"

And just for the sake of testing, if I do

window.matchMedia('(max-width: 567px) and (max-aspect-ratio: 1/2)').media

Firefox returns

"(max-width: 567px) and (max-aspect-ratio: 1 / 2)"

while Safari/Chrome return

window.matchMedia('(max-width: 567px) and (max-aspect-ratio: 1/2)').media

https://codepen.io/webcompat/pen/abZbvMV
illustrating the differences in between chrome and Firefox.
Capture d’écran 2020-10-07 à 13 48 57

https://drafts.csswg.org/cssom-view/#dom-window-matchmedia

Return a new MediaQueryList object, with the context object’s associated Document as the document, with parsed media query list as its associated media query list.

Then https://drafts.csswg.org/cssom-view/#media-query-list

A MediaQueryList object has an associated media which is the serialized form of the associated media query list.

Then https://drafts.csswg.org/cssom/#serialize-a-media-query-list

To serialize a media query list run these steps:

  1. If the media query list is empty, then return the empty string.
  2. Serialize each media query in the list of media queries, in the same order as they appear in the media query list, and then serialize the list.
window.matchMedia('(max-width: 100px) and (max-aspect-ratio: 1/1)').media
  • So Safari and Chrome have a bug on the order?
  • And Firefox a bug on the serialization of aspect-ratio value?

Is the specification clear enough?

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