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

Problem with removed parenthesis from calc before var #113

Closed
shrpne opened this issue Aug 31, 2020 · 5 comments · Fixed by #159
Closed

Problem with removed parenthesis from calc before var #113

shrpne opened this issue Aug 31, 2020 · 5 comments · Fixed by #159
Labels
bad-output postcss-calc produces incorrect output bug

Comments

@shrpne
Copy link

shrpne commented Aug 31, 2020

Original issue cssnano/cssnano#645

This valid css

--aspect-ratio: 16/9;
padding-top: calc(100% / (var(--aspect-ratio)));

becomes invalid after cssnano compilation, because cssnano removes parenthesis around of var()

Chrome and Firefox don't respect the var() without parenthesis around it and so the code is not working as expected.

Test case: https://jsfiddle.net/z7bsn1r8/4/

@Semigradsky
Copy link
Member

Is it the browser bug? Why parenthesis needed around of var()?

@shrpne
Copy link
Author

shrpne commented Aug 31, 2020

I believe it's not a browser bug. Parenthesis are needed because of math:
100 / (16/9) = 56.25
100 / 16/9 = 0.69

@Semigradsky Semigradsky added the bug label Sep 1, 2020
@coreyworrell
Copy link

Probably related #115

@dangelion
Copy link

Any news on this huge bug, it's very blocking...

@ludofischer
Copy link
Collaborator

It's harder to fix than it seems, because the current parser does not distinguish:

100% / (var(--aspect-ratio))

from

100% / var(--aspect-ratio)

ludofischer added a commit that referenced this issue Jan 10, 2022
ludofischer added a commit that referenced this issue Jan 10, 2022
ludofischer added a commit that referenced this issue Jan 10, 2022
Modify the parser to track parenthesized expressions.
Keep the parentheses if a function is inside.

Fix #113
Fix #115
ludofischer added a commit that referenced this issue Jan 10, 2022
Modify the parser to track parenthesized expressions.
Keep the parentheses if a function is inside.

Fix #113
Fix #115
ludofischer added a commit that referenced this issue Jan 10, 2022
Modify the parser to track parenthesized expressions.
Keep the parentheses if a function is inside.

Fix #113
Fix #115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad-output postcss-calc produces incorrect output bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants