Operator precedence is not preserved
See original GitHub issueSource:
:root {
--fluid-min-width: 320;
--fluid-max-width: 1140;
--fluid-screen: 100vw;
--fluid-bp: calc(
(var(--fluid-screen) - ((var(--fluid-min-width) / 16) * 1rem)) /
((var(--fluid-max-width) / 16) - (var(--fluid-min-width) / 16))
);
}
7.0.4 outputs:
:root {
--fluid-min-width: 320;
--fluid-max-width: 1140;
--fluid-screen: 100vw;
--fluid-bp: calc(
(var(--fluid-screen) - var(--fluid-min-width) / 16 * 1rem) /
(var(--fluid-max-width) - var(--fluid-min-width)) / 16
);
}
The output should instead be:
:root {
--fluid-min-width: 320;
--fluid-max-width: 1140;
--fluid-screen: 100vw;
--fluid-bp: calc(
(var(--fluid-screen) - (var(--fluid-min-width) / 16) * 1rem)) /
((var(--fluid-max-width) - var(--fluid-min-width)) / 16
);
}
postcss-calc is removing the necessary parentheses and affecting the operator precedence.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Operator Precedence Considered Harmful - Wiki
The problem with operator precedence is that it's yet another thing a programmer has to memorize about the language he's using. And since...
Read more >Ambiguous operator precedence, please explain why ...
Precedence is not the same as order of evaluation. Precedence simply determines what operands and operators belong together.
Read more >Operator precedence - Microsoft Learn
Operations within parentheses are always performed before those outside. Within parentheses, however, operator precedence is maintained.
Read more >Ask Hackaday: Is There A Legit Use For Operator Precedence?
APL is a programming language that doesn't have operator precedence. Simply because that language has so many operators that no one would be ......
Read more >Operator Precedence and Associativity in C - GeeksforGeeks
// Associativity is not used in the below program. // Output is compiler dependent. ... This is necessary, otherwise, there won't be any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have same issue with
7.0.4
which comes withparcel@2.0.0-nightly.400
.I only spotted this today on production sites with our responsive iframe containers, where we set an inline HTML
style
attribute with correct iframe aspect ratio, and pass that to Sass to evaluatepadding-top
as per this CSS Tricks article:Output in DEV mode with
Parcel start
:Output in PROD mode after with
Parcel build
:I’ve given up waiting for a fix for this.
I’m now using the new standard CSS
aspect-ratio
property in supported browsers, and a hardcodedpadding-top
hack withoutcalc()
for older browsers.