Skip to content
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

CSS : Whitespaces removed around operator of calc() function #84

Closed
brivalin opened this issue Aug 4, 2022 · 11 comments
Closed

CSS : Whitespaces removed around operator of calc() function #84

brivalin opened this issue Aug 4, 2022 · 11 comments
Assignees
Labels
Milestone

Comments

@brivalin
Copy link

brivalin commented Aug 4, 2022

I'm facing a problem when optimizing CSS files containing the CSS function calc(), whitespaces inside this function are removed.

This problem only appear from 2.5.0 version. Previous versions didn't remove these whitespaces.

To be interpreted by browsers, the calc() function must have whitespaces around operator '-' or '+'.
Then, the expected behavior should be to not remove whitespaces for calc() function.

To reproduce the problem, you can use this CSS code and optimize it with plugin :
height: calc(100vh - 20px);

You should get this :
height: calc(100vh-20px);

@melloware
Copy link
Member

See: #75

@melloware
Copy link
Member

So you are saying

height: calc(100vh - 20px);

Should stay

height: calc(100vh - 20px); ?

@melloware
Copy link
Member

Hmm can you also look at the unit test in the commit?

f95ee29

@brivalin
Copy link
Author

brivalin commented Aug 4, 2022

So you are saying

height: calc(100vh - 20px);

Should stay

height: calc(100vh - 20px); ?

Yes, Chrome says that :
calc(100vh - 20px) is valid
but all
calc(100vh -20px) is invalid
calc(100vh- 20px) is invalid
calc(100vh-20px) is invalid

@melloware
Copy link
Member

let me update the unit test

@melloware melloware self-assigned this Aug 4, 2022
@melloware melloware added the bug label Aug 4, 2022
@melloware melloware added this to the 2.5.2 milestone Aug 4, 2022
@melloware
Copy link
Member

Good catch! It was missing vh see my commit and updated unit test. a5de5c4

@brivalin
Copy link
Author

brivalin commented Aug 4, 2022

Thank you for the correction 👍
But from this correction I don't understand why It worked in 2.4.1 version and not 2.5.x ?

@melloware
Copy link
Member

I think its because of #75 that I fixed actually made this issue exposed. Before 75 the code must have handled this scenario but not the other one. Very interesting. I will release 2.5.2 tomorrow!

@melloware
Copy link
Member

2.5.2 is in Maven Central if you want to give it a try.

@brivalin
Copy link
Author

brivalin commented Aug 5, 2022

I updated to 2.5.2 and it works as expected.
Thank you ! 🙂

@melloware
Copy link
Member

Thanks for reporting it and testing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants