-
Notifications
You must be signed in to change notification settings - Fork 715
[cssom] Specify serialization principle for shorthands #878
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
Though the compat principle I was talking about was different: that when new features are introduced to a property, and a value can be expressed in an old-style syntax or a new-style syntax, we try to serialize to the old-style syntax even if it's longer than the new-style syntax. |
It's probably also worth trying to list principles for serialization more generally, such as:
(probably more) |
Does this actually belong in a spec? Is the audience spec editors to help them make good specs, or is it implementors who would refer to this to know how to implement correct serialization for properties? |
Given that generally spec editors don't tend to specify the exact serialization of all the given values of a given property, relying on CSSOM instead, I think it should be on a spec, yeah... |
I also think it's sometimes a good idea for one spec to have material that is targeted at other spec authors. This can help make sure design principles are appropriately agreed on and widely-enough known, and help others catch when they're not followed. I think this is a case where that would be a good idea. |
Yeah, we write guidelines for spec editors in specs at times, if for no other reason than to serve as an opportunity for non-editors to catch the inconsistency and tell us we've done something wrong. |
Another place to mention this might be https://w3ctag.github.io/design-principles/ |
I do not know if it can be defined as a serialization principle but I think that a shorthand should serialize if (this serialization would round trip and) its reset-only sub-properties are declared with their initial value or the style.border = '1px solid black'
style.borderImageOutset = '0'
console.log(style.border) // Chrome/Firefox: '1px solid black
style.borderImageOutset = '0px'
console.log(style.border) // Chrome/Firefox: '' |
Why? I don't think we should special-case initial over other css-wide keywords. |
I agree with @emilio's objection to the I agree that a shorthand should serialize if its reset-only subproperties are their initial value (i.e., what they're reset to). Much of this should be specified generally in CSSOM rather than specified as a principle for other specifications to follow. I'm not sure that it is, though. |
I expressed myself badly because I do not have a strong opinion on whether a shorthand should serialize even if one of its sub-property is I guess you also both think that
Ok. Sorry to be off topic then. I am pretty sure it is not defined in CSSOM. Off topicI would expect to see these "rules" in serialize a CSS value, in which the serialization principles are also defined. I cannot find your comment in which you list these "rules". I was quite relieved to realize that it was identical to mine (I think).
|
https://drafts.csswg.org/cssom/#serialize-a-css-declaration-block
The spec currently tries to serialize properties with the minimal set of component values, i.e. omitting optional ones that are the initial value. But @dbaron points out that some properties may need to be different because of browser legacy and web compat. So the principle should be minimal with exceptions for web compat.
The text was updated successfully, but these errors were encountered: