postcss / postcss-calc

PostCSS plugin to reduce calc()
MIT License
213 stars 34 forks source link

incorrect reduction of subtraction css-variable from zero #110

Closed csr632 closed 3 years ago

csr632 commented 3 years ago

While https://github.com/postcss/postcss-calc/issues/88 is fixed by https://github.com/postcss/postcss-calc/pull/93 , this case still has bug: calc(0px - (var(--foo, 4px) / 2)) is reduced into: calc(var(--foo, 4px)/2)

csr632 commented 3 years ago

Two test cases can be added:

test(
  'should reduce substracted expression from zero (css-variable)',
  testValue,
  'calc( 0px - (var(--foo, 4px) / 2))',
  'calc( 0px - (var(--foo, 4px) / 2))',
);

test(
  'should reduce substracted expression from zero (unknown unit)',
  testValue,
  'calc( 0px - (4unknown / 2))',
  'calc( 0px - (4unknown / 2))',
);

You can see the error when you add these test cases to tests