[csswg-drafts] rules for serializing calc() trees sort + and * values by type but not - and / values (#8803)

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

== rules for serializing calc() trees sort + and * values by type but not - and / values ==
If I interpret the [rules for serializing a calc tree](https://drafts.csswg.org/css-values-4/#serialize-a-calculation-tree) literally, they define (in steps 6 and 7) rules for sorting the children of Sum and Product nodes.  The rules for constructing these nodes in the definition of [parse a calculation](https://drafts.csswg.org/css-values-4/#parse-a-calculation) describe how the things preceded by `-` are put in Negate nodes and the things preceded by `/` are put in Invert nodes.

Based on these definitions, it seems like the rules for sorting the children of Sum and Product nodes mean that the terms not preceded by `-` or `/` and that are not `()`-blocks or other math functions appear first, sorted by unit, and then the terms preceded by `-` or `/` or nested in `()`-blocks or other math functions appear afterwards, in the order originally given.

This seems like a strange result.  I would not expect `+` and `-` to be treated this differently.

I have not yet looked into what implementations do, other than noting that [Chromium does not do sorting and the code doesn't really match the spec's structure](https://bugs.chromium.org/p/chromium/issues/detail?id=1180387#c22).

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 5 May 2023 21:11:14 UTC