Skip to content

wrong output with calc() #742

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

Closed
liuwf2012 opened this issue Apr 30, 2019 · 5 comments
Closed

wrong output with calc() #742

liuwf2012 opened this issue Apr 30, 2019 · 5 comments
Labels

Comments

@liuwf2012
Copy link

image

initial state

.class {
  width: calc(-25rem - (1280px - 100vw) * 0.5);
}

correct minimization

.class{
  width: calc(-25rem - 640px + 50vw);
}

actual minimization

.class{
  width: calc(-25rem - 640px - 50vw);
}
@alexander-akait
Copy link
Member

Bug in postcss calc

@cduivis
Copy link

cduivis commented Jul 8, 2020

I just encountered the same issue:

initial code:
calc(0.7 * 560 * (1220px - 100vw) / 1220 + 0.1 * 560 * (1220px - 50vw) / 1220)
resulting code:
calc(478240px - 39200vw + 68320px - 2800vw)

I see this bug was already reported in 2019 is some actually picking this up?

Btw for such complex behavior as redefining calculations, it would be a good thing to define some unit tests as this is easily broken.

@wszydlak
Copy link

wszydlak commented Jun 30, 2021

Bug in postcss calc

@alexander-akait Could you provide issue number in postcss-calc? Is this already fixed?

@ludofischer
Copy link
Collaborator

ludofischer commented Aug 18, 2021

@alexander-akait Could you provide issue number in postcss-calc? Is this already fixed?

It's likely this one: postcss/postcss-calc#137 edit: actually wrong issue, the referenced issue is a crash, this one outputs the wrong value.

@ludofischer
Copy link
Collaborator

Fixed in cssnano 5.0.15.

calc(0.7 * 560 * (1220px - 100vw) / 1220 + 0.1 * 560 * (1220px - 50vw) / 1220)

now returns

calc(448px - 34.42623vw)

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

5 participants