Skip to content

Complex calc function simplifying incorrectly #45

@paulmskim

Description

@paulmskim

This was reported in postcss-cssnext, but it was recommended to be reported here. The post below is nearly identical to the link below:

MoOx/postcss-cssnext#450

In version 2.11.0 of postcss-cssnext, complex calc functions would not be simplified, so they would remain as is when compiled. However, I upgraded postcss-cssnext and in version 3.1.0, postcss-cssnext tries to simplify the calc function, but does so incorrectly. Maybe I'm doing something wrong on my end, but upgrading from 2.11.0 to 3.1.0 seems to mess up the result. For example:

calc(100% + (2 * 100px) - ((75.37% - 63.5px) - 900px));

incorrectly simplifies and compiles to:

calc(100% + 200px - 75.37% - 963.5px));

The double negative here is not handled properly.

Also, the following:

calc(((((100% + (2 * 30px) + 63.5px) / 0.7537) - (100vw - 60px)) / 2) + 30px);

incorrectly simplifies and compiles to:

calc((176.0366% + 217.4052px - 100vw - 60px) / 2 + 30px);

I have no idea what is happening here, but it's completely wrong.

I know I could simplify my calcs, but there are some semantics behind organizing it this way in my code.

In version 2.11.0, when the compiled calcs were sent to the browser without being simplified, they worked as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions