Skip to content

[css-values-4] Allow more simplification of operator nodes #9616

@cdoublev

Description

@cdoublev

Maybe returning a result in its canonical unit should not be mandatory?

  1. If root is an operator node that’s not one of the calc-operator nodes, and all of its calculation children are numeric values with enough information to compute the operation root represents, return the result of running root’s operation using its children, expressed in the result’s canonical unit.

https://drafts.csswg.org/css-values-4/#simplify-a-calculation-tree

It prevents simplifying min(1em) as calc(1em) (related: #9559), clamp(0em, 2em, 1em) as calc(1em), round(1.1em, 1em) as calc(1em), etc.

Chrome/FF currently simplify min(max(1%, -1%)) as max(1%, -1%). There does not seem to be any corresponding WPT tests. Support for other math functions is still low so I have not tested them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions