Open Manishearth opened 7 years ago
cc @SimonSapin
Agenda+ to ask which level of css-backgrounds this goes into so that I can triage appropriately.
The Working Group just discussed Define serialization for background shorthand
, and agreed to the following resolutions:
RESOLVED: postpone this until there's further evidence of use cases and move this to L4 if there is evidence
So, the css-backgrounds spec currently does not include the truncation/elongation of value lists as part of the process of computing values. So the computed value--the value that is used for inheritance--definitely is the length specified per spec.
As for the output of the CSSOM APIs, if we normalize the list lengths, then roundtripping a value gives different behavior than its initial declaration.
Is serialization (of a shorthand) allowed to fail if parsing hasn't?
I don't know enough about CSSOM to answer this question.
So we have several options here:
I don't know what's the best option. @dbaron ?
More observations of browser behavior:
'background' syntax is specified as
background = <bg-layer># , <final-bg-layer>
<bg-layer> = <bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box>
<final-bg-layer> = <‘background-color’> || <bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box>
However, browsers do not respect the above serialization order - test page
Edge serializes inline style using
<bg-layer> = <bg-image> || <attachment> || <repeat-style> || <bg-position> [ / <bg-size> ]? || <box> || <box>
<final-bg-layer> = <bg-image> || <attachment> || <repeat-style> || <bg-position> [ / <bg-size> ]? || <box> || <box> || <‘background-color’>
Firefox serializes inline style using
<bg-layer> = <bg-image> || <repeat-style> || <attachment> || <bg-position> [ / <bg-size> ]? || <box> || <box>
<final-bg-layer> = <‘background-color’> || <bg-image> || <repeat-style> || <attachment> || <bg-position> [ / <bg-size> ]? || <box> || <box>
Blink and WebKit serialize inline style using
<bg-layer> = <bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box>
<final-bg-layer> = <bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box> || <‘background-color’>
Edge and Firefox serialize computed style as empty string.
Blink serializes computed style using
<bg-layer> = <bg-image> || <repeat-style> || <attachment> || <bg-position> [ / <bg-size> ]? || <box> || <box>
<final-bg-layer> = <‘background-color’> || <bg-image> || <repeat-style> || <attachment> || <bg-position> [ / <bg-size> ]? || <box> || <box>
WebKit serializes computed style by interleaving information from the different layers.
This returns
""
on Firefox and"url("a") no-repeat, url("b") no-repeat, no-repeat"
on Chrome.This returns
""
on Firefox and"url("a") no-repeat, url("b") repeat, url("c")"
on Chrome.In case the number of values set is the same, Firefox does return a value:
(
"url("a") no-repeat scroll 0% 0%, url("b") repeat scroll 0% 0%, transparent url("c") no-repeat scroll 0% 0%"
on Firefox,"url("a") no-repeat, url("b") repeat, url("c") no-repeat"
on Chrome)Firefox seems to only serialize when all set longhands are of the same length (and when it does, it serializes to all default values). Chrome always serializes, and just prints out whatever was set.
This should probably be specced. Important questions to answer:
background-image
longhand?background-image
?