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
feat(css/minifier): Handle nested calc()
#6153
Conversation
@@ -1 +1 @@ | |||
.class1{width:calc(100vw/2 - 6px)}.class2{width:500px}.class3{width:calc(0 - 10px)}.class4{width:calc(0 - calc(1px + 1em))}.class5{width:calc(0 - (100vw - 10px)/2)}.class6{width:calc(10px - 100vw)}.class7{width:calc(0px - (100vw - 10px)*2)}.class8{width:calc(-10px - 100vw)}.class9{width:calc(0px - var(--foo,4px)/2)} | |||
.class1{width:calc(100vw/2 - 6px)}.class2{width:500px}.class3{width:calc(0 - 10px)}.class4{width:calc(0 - 1px - 1em)}.class5{width:calc(0 - (100vw - 10px)/2)}.class6{width:calc(10px - 100vw)}.class7{width:calc(0px - (100vw - 10px)*2)}.class8{width:calc(-10px - 100vw)}.class9{width:calc(0px - var(--foo,4px)/2)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
width:calc(0 - 1px - 1em)
-> width:calc(-1px - 1em)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nested calc()
is like (
and )
, so I think we should handle it not in transform_calc_value_into_component_value
, we should handle them inside calculation.
Because if you will compress width:calc(100px - (1px - 1em))
all works fine
dd3fa97
to
79cb9a7
Compare
@alexander-akait i'm not sure to understand your comment, i added the "nested calc" handling into the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, there are some impvomenets more, like width:calc(2.25rem - 0px)
, but let's do it another PR, because it is not related to nested calc
@kdy1 Ready to review |
calc()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll rebase/merge this after publishing a new version
swc-bump:
- swc_css_minifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
@alexander-akait i'll work on removing zeroes this week. |
Thanks |
Description:
Handle nested
calc()
:calc(100% - calc(50% + 25px))
=>calc(50% + 25px)
BREAKING CHANGE:
Related issue (if exists):