Skip to content

[css-values] note counter-intuitive interpretation of unitless 0 inside calc() #1114

Closed
@mgiuffrida

Description

@mgiuffrida

Section 8.1.2 **calc() Type Checking does not explicitly indicate how a unitless 0 inside a calc() expression is treated. For example:

left: calc(0 - 5px);

It's not clear whether this expression is invalid. Inside calc((), the types of arguments to the - operator must be compatible, and the rhs is of type dimension<length>. But what is the type of the lhs: number or dimension<length>?

Since section 5 says:

for zero lengths the unit identifier is optional (i.e. can be syntactically represented as the <number> '0'

I would argue that interpreting 0 as being of type dimension<length> would be valid, and would be more in line with developer expectations. However, this was discussed in 2010 with @tabatkins agreeing the 0 should cause a parse error. That's fine, but it would be helpful if the fact that 0 is never treated as a dimension inside calc() were explicitly noted in the spec (which was also agreed upon in that discussion).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions