Skip to content

[css-typed-om][css-values] Clarification on percieved ambiguity between WPT and calc() specification #10752

Description

@weinig

I spent the last few days working on a new implementation of calc() and have run into some regressions in WPT tests where I am not sure if the tests are in error, or my implementation (and interpretation of the spec) is.


The first type of failure seen is due to no removing 0px from computed values. For example, for the test css/css-flexbox/parsing/flex-basis-computed.html:

- PASS Property flex-basis value 'calc(10% + 0px)'
+ FAIL Property flex-basis value 'calc(10% + 0px)' assert_equals: expected "10%" but got "calc(10% + 0px)"

Back in 2019, there was a discussion on this #3482 (comment), where it is stated the 0px in these cases should go away, but I wanted to make sure that still held, and if so, double down on clarifying this in the spec, as it wasn't clear to me why this would be the case, as the note in the simplification section states:

NOTE: Zero-valued terms cannot be simply removed from a Sum; they can only be combined with other values that have identical units. (This is because the mere presence of a unit, even with a zero value, can sometimes imply a change in behavior.)


The second kind of failure is due to use of (px / px).

In addition to the one I noted in #10733, another example is the test css/css-properties-values-api/register-property-syntax-parsing.html

- PASS syntax:'<length>', initialValue:'calc(5px * 3px / 6px)' is invalid
+ FAIL syntax:'<length>', initialValue:'calc(5px * 3px / 6px)' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw

Is there any reason use of unit algebra in this circumstance would be illegal?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions