MoOx / postcss-cssnext

`postcss-cssnext` has been deprecated in favor of `postcss-preset-env`.
https://moox.io/blog/deprecating-cssnext/
MIT License
5.3k stars 189 forks source link

Complex calc function simplifying incorrectly #450

Closed paulmskim closed 6 years ago

paulmskim commented 6 years ago

In version 2.11.0, 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.

MoOx commented 6 years ago

Will need to be reported and fixed in https://github.com/MoOx/reduce-css-calc

MoOx commented 6 years ago

postcss-cssnext has been deprecated in favor of postcss-preset-env. Read more at https://moox.io/blog/deprecating-cssnext/