csswg-drafts
csswg-drafts copied to clipboard
[cssom-1] Serialization of feature values
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) |
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.
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".
It says
Probably should distinguish between declared and computed / resolved values.
Right, and "the unit in its canonical form" does not necessarily mean "the dimension in its canonical unit". I removed the row (thanks again).