w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.48k stars 660 forks source link

[cssom-1] Serialization of feature values #11041

Open cdoublev opened 1 week ago

cdoublev commented 1 week ago

Serializing Media Feature Values is poorly defined.

This is not really important but hey, it could simply be replaced with serializing a CSS component value: keywords in lowercase, base 10 numbers, etc.

In current version of Chrome and FF:

Input Chrome FF Expected
orientation: PORTRAIT orientation: portrait orientation: portrait orientation: portrait
aspect-ratio: 1 aspect-ratio: 1 / 1 aspect-ratio: 1 / 1 aspect-ratio: 1 / 1
width: 0 width: 0 width: 0px width: 0px
width: 1.0px width: 1px width: 1px width: 1px
width: calc(1px * 2) width: calc(2px) width: calc(2px) width: calc(2px)
Loirooriol commented 1 week ago

Lengths don't seem to serialize with the canonical unit at declaration-value time:

var div = document.createElement("div");
div.style.width = "1in";
div.style.width; // "1in"

Also the value of the color feature should apparently be an <integer>, so 1.0 in invalid, and see #10238 for 1e1.

cdoublev commented 1 week ago

Thanks, I replaced color: 1.0 with width: 1.0px and removed the row with color: 1e1.

However, CSSOM wants dimensions to serialize with the "<number> [component] followed by the unit in its canonical form".

Loirooriol commented 1 week ago

It says

Probably should distinguish between declared and computed / resolved values.

cdoublev commented 1 week ago

Right, and "the unit in its canonical form" does not necessarily mean "the dimension in its canonical unit". I removed the row (thanks again).