[csswg-drafts] [css-grid] Resolved values of grid-template-rows/columns don't round-trip (#4475)

Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-grid] Resolved values of grid-template-rows/columns don't round-trip ==
According to @fantasai in https://github.com/w3c/csswg-drafts/issues/4444#issuecomment-548006702,

> Roundtripping getComputedStyle() values is probably the most fundamental rule about defining them.

However, `grid-template-rows` and `grid-template-columns` don't always round-trip. That's because they set explicit tracks, which start just after the 1st grid line. However, when serialized, they also include implicit tracks, which may exist before the 1st grid line.

```js
gridContainer.style.gridAutoRows = "1px";
gridContainer.style.gridTemplateRows = "2px";
var cs = getComputedStyle(gridContainer);
cs.gridTemplateRows; // "2px"
gridItem.style.gridRow = "auto / 1";
gridContainer.style.gridTemplateRows = cs.gridTemplateRows; // "1px 2px"
gridContainer.style.gridTemplateRows = cs.gridTemplateRows; // "1px 1px 2px"
gridContainer.style.gridTemplateRows = cs.gridTemplateRows; // "1px 1px 1px 2px"
gridContainer.style.gridTemplateRows = cs.gridTemplateRows; // "1px 1px 1px 1px 2px"
```

On the one hand, knowing the final size of these implicit tracks can be useful. On the other hand, failing to round-trip sucks.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4475 using your GitHub account

Received on Thursday, 31 October 2019 12:28:59 UTC