Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex calc function simplifying incorrectly #45

Closed
paulmskim opened this issue Mar 11, 2018 · 1 comment
Closed

Complex calc function simplifying incorrectly #45

paulmskim opened this issue Mar 11, 2018 · 1 comment
Labels

Comments

@paulmskim
Copy link

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.

roderickhsiao referenced this issue in roderickhsiao/react-aspect-ratio Jan 9, 2019
@Semigradsky
Copy link
Collaborator

Fixed by #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants