Re: [css-houdini-drafts] [css-typed-om] Serialization of CSSStyleValues constructed from string

So I tried implementing this for "nested/recursive objects" like `CSSPositionValue`, `CSSTransformValue` and `CSSNumericValue`s. From what we've discussed, it sounds like the "input preservation" behaviour applies to subobjects as well, e.g.

```
const result = CSSStyleValue.parse("width", "calc(1.0% - 1.0px)");
// result is CSSMathSum(1.0%, CSSMathNegate(1.0px)).
result.toString(); // calc(1.0% - 1.0px)
result.values[0].toString() // 1.0%
result.values[1].toString() // - 1.0px
```

The main difficulty is keeping track of what part of the original input string each subobject serializes to. AFAIK this would be quite difficult to do in Blink at the moment.

Another issue is that serializing subobjects may not result in a valid string. In the example above, `result.values[1]` serializes to `- 1.0px` which I believe is not valid? It should really serialize to `calc(- 1.0px)`, but that no longer matches the original input string.

Would it be possible to only have this input preservation behaviour for the "root" object? In the above example, `CSSMathSum` is required to preserve the input, but its children doesn't have to.

-- 
GitHub Notification of comment by darrnshn
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/556#issuecomment-360290404 using your GitHub account

Received on Wednesday, 24 January 2018 22:09:12 UTC