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

Should not strip calc(var(--cp)) expressions #725

Closed
lunelson opened this issue Mar 26, 2019 · 4 comments
Closed

Should not strip calc(var(--cp)) expressions #725

lunelson opened this issue Mar 26, 2019 · 4 comments

Comments

@lunelson
Copy link

Currently cssnano assumes that calc(var(--myvar)) will always be equal to var(--myvar) but this is not a safe assumption. var() expressions can contain arbitrary numeric expressions, and may need a calc() wrapper in order to be valid. Example:

p {
  --fz: (4em / 2);
  font-size: calc(var(--fz));
}

cssnano will strip this down to the following, which is not valid:

p{--fz:(4em/2);font-size:var(--fz)}
@alexander-akait
Copy link
Member

@lunelson can you provide example when this optimization doesn't work as expected (codepen or other services)

@lunelson
Copy link
Author

If you check the following pen you can see that font-size: calc(var(--fz)); works, but font-size:var(--fz); (which is what you get with cssnano's minification) does not:

https://codepen.io/lunelson/pen/OqGEgG

@alexander-akait
Copy link
Member

Yep, bug in postcss-calc, thanks for issue

@alexander-akait
Copy link
Member

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

No branches or pull requests

2 participants