postcss / postcss-calc

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

fix: preserve calc when extra parentheses are used #187

Closed tannerdolby closed 1 year ago

tannerdolby commented 1 year ago

Fixes #181

This fix allows calc to be printed when calc((...)) is encountered. The bug occurred because the AST was 'type: 'ParenthesizedExpression' which didn't satisfy the shouldPrintCalc check in stringifier.js. The test I added piggy backs on the work started in #180. All the original tests pass with this addition, but I am new to the codebase so I very well could be missing some things.

https://github.com/cssnano/cssnano/issues/1490#issuecomment-1534215112

TODOs:

ludofischer commented 1 year ago

Good job! I think we're very close to being able to simplify the external parentheses completely. Regarding the second TODO, do you think there's a reason to preserve the space around the division operator?

tannerdolby commented 1 year ago

@ludofischer Thank you! After implementing your suggested changes, it seems we're very close to completely fixing the bug. In regards to the second TODO, I don't think there is any reason to preserve the space around the division operator. Especially because that space isn't preserved in other tests within test/index.js so I think it makes sense to keep things as is.