[csswg-drafts] [css-typed-om] Should min and max methods on CSSNumericValue preserve percentage values? (#9628)

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

== [css-typed-om] Should min and max methods on CSSNumericValue preserve percentage values? ==
CSSNumericValues have a [min](https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-min) and a [max](https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-max) method.

If min or max is called and all of the values are CSSUnitValues with the same unit, the steps of the method will return early with a CSSUnitValue with the minimum or maximum value respectively. 

> If all of the [items](https://infra.spec.whatwg.org/#list-item) in values are [CSSUnitValue](https://drafts.css-houdini.org/css-typed-om-1/#cssunitvalue)s and have the same [unit](https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunitvalue-unit), return a new [CSSUnitValue](https://drafts.css-houdini.org/css-typed-om-1/#cssunitvalue) whose [unit](https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunitvalue-unit) internal slot is set to this’s [unit](https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunitvalue-unit) internal slot, and [value](https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunitvalue-value) internal slot is set to the minimum of the [value](https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunitvalue-value) internal slots of the [items](https://infra.spec.whatwg.org/#list-item) in values.

But, if the unit is `percent` we can't really know what value it will resolve against at this point. Since percentages might resolve against a negative basis, returning a CSSUnitValue with the minimum or maximum of the values could end up with the opposite result of what is expected (see [simplify a calculation tree](https://drafts.csswg.org/css-values-4/#simplify-a-calculation-tree)).

Should this step in the methods be skipped if the unit is `percent`?



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


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

Received on Thursday, 23 November 2023 10:48:48 UTC