-
Notifications
You must be signed in to change notification settings - Fork 711
[cssom] Define serialization of specified values with more detail #5642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Some common patterns: Remove optional components when the default value was provided (according to the shortest serialization principle)document.body.style.margin = "1px 1px 1px 1px";
document.body.style.margin; // "1px" in Chromium, WebKit and Firefox document.body.style.gridAutoFlow = "row dense";
document.body.style.gridAutoFlow; // "dense" in Firefox (stays as "row dense" in Chromium and WebKit) Add optional components that were omitted (against the shortest serialization principle)document.body.style.counterIncrement = "c";
document.body.style.counterIncrement; // "c 1" in Chromium, WebKit and Firefox document.body.style.borderTop = "solid";
document.body.style.borderTop; // "medium solid" in Firefox (stays as "solid" in Chromium and WebKit) Normalize to canonical orderdocument.body.style.flexFlow = "wrap column";
document.body.style.flexFlow; // "column wrap" in Chromium, WebKit and Firefox |
If I may, what is the rationale for pattern 1 (remove optional component values)? It is always extra work, for what purpose? EDIT: from reading multiple related issues, serialization to an older syntax, which may me shorter or longer, can help back-compat. I wonder what would be the conditions/scenarios where this backward compatibility requirement might be useful, though. |
It brings the value closer to what humans would likely write, which makes it easier to read. |
I had figured it that too, but it seems less important than back-compat. And for shorthand (eg. |
I do not know if math functions generally fall into the "weird case" category but the SSP is currently applied inconsistently with them. For example, Serialization in CSS Images 3 requires omitting components when possible without changing the meaning:
(The same section in CSS Images 4 serializes Chrome/Firefox omit Obviously color stop list is a "weird case" but I think there are many cases similar to the first. Eg. Chrome/FF do not serialize specified I guess browsers do not try too hard to resolve values until they know it is required for rendering, which makes me think that not applying the SSP for specified values (except for backward-compatibility) would be way more simple. |
I did an in-depth specific research on serialization of optional numeric values, or optional keyword values mapping to a numeric value, in Chrome and Firefox. They usually only seem to be omitted when they are strictly equal to a default value or an initial longhand value, without applying any resolution before the comparison (presumably with serialized strings):
Two numerics with a value of Exceptions (probably not exhaustive)
|
Serialization of computed values is generally governed by applying the shortest-serialization principle to the computed value. It's a bit handwavey, and there are some exceptions, but overall it works.
But specified values do not seem to serialize according to the SSP in general; instead, they seem to usually retain more details of what the author originally wrote. Sometimes it's literally the original text, sometimes some light modification is done. (For example, Chrome sorts the 'contain' keywords specified, but doesn't combine them into shorthands like it'll do for computed values.)
I suspect there's a lot of non-interop around this, but we should have more details at least on general principles, even if we don't have all the weird specifics.
The text was updated successfully, but these errors were encountered: