-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Description
COPY OF cssnano/cssnano#901
Describe the bug
A CSS input with a calc function using css variables strips away factors from multiplications:
calc(var(--foo) * 0.4 - var(--bar) * 0.4);
... will get converted to ...
calc(var(--foo) - var(--bar));
... and that is incorrect. This happens using cssnanos default preset.
Input given:
.baz {
--correct-1: calc(var(--foo) * 0.2 - var(--bar) * 0.8);
--correct-2: var(--foo) * 0.4 - var(--bar) * 0.4;
--incorrect-1: calc(var(--foo) * 0.4 - var(--bar) * 0.4);
--incorrect-2: calc(var(--foo) * 0.5 - var(--bar) * 0.5);
--incorrect-3: calc((var(--foo) * 0.5) - (var(--bar) * 0.5));
}Expected output
.baz {
--correct-1: calc(var(--foo) * 0.2 - var(--bar) * 0.8);
--correct-2: var(--foo) * 0.4 - var(--bar) * 0.4;
--incorrect-1: calc(var(--foo) * 0.4 - var(--bar) * 0.4);
--incorrect-2: calc(var(--foo) * 0.5 - var(--bar) * 0.5);
--incorrect-3: calc((var(--foo) * 0.5) - (var(--bar) * 0.5));
}Actual output
.baz {
--correct-1: calc(var(--foo) * 0.2 - var(--bar) * 0.8);
--correct-2: var(--foo) * 0.4 - var(--bar) * 0.4;
--incorrect-1: calc(var(--foo) - var(--bar));
--incorrect-2: calc(var(--foo) - var(--bar));
--incorrect-3: calc(var(--foo) - var(--bar));
}Repo for reproduction
https://github.com/Sanderand/css-nano-calc-bug
Additional context
"dependencies": {
"cssnano": "4.1.10",
"postcss-cli": "7.1.0"
},const cssnano = require('cssnano');
module.exports = {
plugins: [
cssnano({ preset: 'default' }),
],
};Disabling the calc optimization is a temporary workaround that I now use. I guess the calc optimization needs to be fixed.
Thanks!
taikn, TSmulkys, loxy, coreyworrell, pklaschka and 1 more
Metadata
Metadata
Assignees
Labels
No labels