[css-grid] Spaces in grid-template-areas serialization · Issue #4335 · w3c/csswg-drafts (original) (raw)

See https://crbug.com/1005364 regarding

element.style.gridTemplateAreas = '". . a b" ". .a b"'; element.style.gridTemplateAreas; // '". . a b" ". .a b"' in Firefox // '". . a b" ". . a b"' in Blink, Webkit

According to https://drafts.csswg.org/css-grid/#valdef-grid-template-areas-string

Both the specified value and computed value of a <string> value of grid-template-areas serializes each null cell token as a single "." (U+002E FULL STOP) and each sequence of whitespace as a single space (U+0020 SPACE).

And by omission I guess that a lack of whitespace shouldn't be serialized as a space?

However, it seems confusing to me because the resolution in #3261 was against preserving the precise string when serializing grid-template-areas, and in favour of normalizing it. And according to https://drafts.csswg.org/css-grid/#valdef-grid-template-areas-string,

A sequence of whitespace, representing nothing (do not produce a token).

So if whitespace doesn't produce tokens when parsing, it doesn't seem unreasonable for me to not track whether some optional space between tokens of different type was specified or not. Then the possibilities are always adding a space separator between tokens like ". . a b" ". . a b", or only doing it if necessary (between tokens of the same type) like ". .a b" ". .a b".