csswg-drafts
csswg-drafts copied to clipboard
[cssom][css-values] Serialization of <number-percentage>?
This is possibly more of a Chrome bug than a spec issue but I thought I'd check: how should brightness(0.5)
and brightness(50%)
be serialized. As-is?
Given this fiddle in Firefox and Edge the two values are serialized as-is, but in Chrome both become brightness(0.5)
. Servo, I believe, does the same as Chrome here so I want to check that Chrome is in fact wrong before changing Servo.
It would definitely be preferable if equivalent declarations serialized to the same value.
Furthermore, serializing to number is probably slightly preferable to percentages, as they are easier to use in JS.
But to make this a general rule (and not just something specific to filter
) would require that <number-percentage>
only be used when numbers and percentages are directly equivalent. Which I think was the agreement from the discussion of calc()
, but I'm not sure.
Serialization is really a matter of CSSOM spec, I believe.
In the serialization section of CSSOM, there is no individual rule for <number-percentage>
, and from CSS Values spec, <number-percentage>
is really just [ <number> | <percentage> ]
so I would suggest we should just serialize it as [ <number> | <percentage> ]
, which means they should be serialized as-is in this case.
Underspecified. I'd prefer they serialize to the same thing too, tho.
WPTs show current browsers serializing specified values as supplied by the author, and serializing getComputedStyle() results using numbers.
They are not generally compatible, so their specified values should be serialized as-is. As for the computed value serialization, that should depend on what the Computed Value is defined to be. It's up to the property/function to define that e.g. <percentage>
values compute to equivalent <number>
s or vice versa.
Retagging against Filters.