You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
YUI Compressor is breaking some CSS, specifically calc(100% + ##px) #59
calc() is specifically called out as "at risk of being dropped during the CR period", but we should probably still address this one, as the blasted spec does - in fact - require at least one whitespace character around + and - operators.
I'm having exactly the same problem. I'm using Jammit to compress the CSS for production and my calc() expressions are breaking because the compressor is removing, sometimes, spaces before and after operators and parenthesis.
I'm having the same issue. Although calc is considered "experimental", it's a great tool to use (and it does work with major browsers).
It would be great to have this fixed; I can't seem to find a workaround.
Has there been any progress on this bug? It's maddening. Nested expressions are still being compressed, which breaks the calc function under Safari and Firefox. It works under Chrome.
Example: (source calcs had spaces been operations)
i attempted to locate which of the many regex's might need tweaking for this but was caught up in the muck and mire of a very long if( ) statement indeed... surely someone who worked on it or familiar with it can have a look?
Does anybody have a list of issues with calc? We've faced with
100% + 6px -> 100%+px
100% - (10% * 6) -> 100% -(10% * 6)
It seems also
(100vw - 40px) * .73) + 40px -> (100vw - 40px) * .73)+ 40px
September 2022 and still broken.
Version 2.4.8 has got several bugs. One of them is described here: https://stackoverflow.com/a/19339287/760777
Version 2.4.9 has never been released.
So back to version 2.4.7
There is the calc bug. Just use the double minus solution.
So
left: calc(100% + 14px);
becomes
left: calc(100 - -14px); /* + replaced with - - because of yuicompressor bug */
Activity
tml commentedon Mar 31, 2013
calc() is specifically called out as "at risk of being dropped during the CR period", but we should probably still address this one, as the blasted spec does - in fact - require at least one whitespace character around + and - operators.
filipewl commentedon Apr 4, 2013
I'm having exactly the same problem. I'm using Jammit to compress the CSS for production and my calc() expressions are breaking because the compressor is removing, sometimes, spaces before and after operators and parenthesis.
Examples:
Original:
calc(100% * 2 + 20px * (2 - 1))Compressed:
calc(100% * 2+20px *(2 - 1))Does anybody know a workaround for this? I see no other option but to exclude this part of the CSS from Jammit's pipeline.
alfredxing commentedon May 12, 2013
I'm having the same issue. Although
calcis considered "experimental", it's a great tool to use (and it does work with major browsers).It would be great to have this fixed; I can't seem to find a workaround.
yetithefoot commentedon Jul 4, 2013
Same here! Vote for this!
DanFinchUK commentedon Jul 4, 2013
Me too.
kmxz commentedon Aug 7, 2013
Same problem troubled me
kris-o3 commentedon Sep 3, 2013
gets compressed as:
i currently have to add a space after the - before the inner expression.
like so:
i have to do this every time i commit css-related changes.
it is making me very sad indeed.
eaoliver commentedon Sep 28, 2013
Has there been any progress on this bug? It's maddening. Nested expressions are still being compressed, which breaks the calc function under Safari and Firefox. It works under Chrome.
Example: (source calcs had spaces been operations)
left: -moz-calc((100% - 106px)/2+64px);
left: -webkit-calc((100% - 106px)/2+64px);
left: calc((100% - 106px)/2+64px);
kris-o3 commentedon Sep 30, 2013
i attempted to locate which of the many regex's might need tweaking for this but was caught up in the muck and mire of a very long if( ) statement indeed... surely someone who worked on it or familiar with it can have a look?
djgilcrease commentedon Sep 30, 2013
We had fixed this in our local version, I just forgot to commit it back for upstream pull request #107
kris-o3 commentedon Sep 30, 2013
great! let us know when the merge has been approved / is complete?
tml commentedon Sep 30, 2013
The PR breaks the build, but it's a huge step forward. Thanks, @djgilcrease!
djgilcrease commentedon Sep 30, 2013
How does it break the build? I was able to run the ant build and all the tests that were passing before changes were still passing.
tml commentedon Sep 30, 2013
See the Travis status on #107
Or just check the build: https://travis-ci.org/yui/yuicompressor/builds/11968385
58 remaining items
sunnybear commentedon Apr 18, 2018
Any news on this? YUI Compressor breaks CSS calc for 5 years!
himanshuwt commentedon Apr 18, 2018
@sunnybear agree with you. 5 years done. And, still I faced the issue "+" then again i replace it with calc(x - - y). :D
sunnybear commentedon Apr 18, 2018
Does anybody have a list of issues with calc? We've faced with
100% + 6px -> 100%+px
100% - (10% * 6) -> 100% -(10% * 6)
It seems also
(100vw - 40px) * .73) + 40px -> (100vw - 40px) * .73)+ 40px
MarjanAshofteh commentedon Jun 4, 2018
@beaktor
using two - beside + works for me too.
thanks
Work around a YUICompressor 2.4.8 bug in CSS calc
ramarro123 commentedon Nov 15, 2018
it's yui compressor still mantained?
DrLightman commentedon Nov 28, 2019
Using YuiCompressor 2.4.8 and the bug is still on.
frangarcia commentedon Jun 4, 2020
This version, https://mvnrepository.com/artifact/com.yahoo.platform.yui/yuicompressor/2.4.9-BSI-2, seems to have fixed the problem. I followed the examples @svaponi added using this file
and when running this command:
java -jar yuicompressor-2.4.9-BSI-2.jar --line-break 0 -o process.css.min file.cssthis output was generated:
body{font-size:calc(50% - 3px);font-size:calc(50% + 3px);font-size:calc(50% + +3px);font-size:calc((50%)+(3px));font-size:calc(50% + (+3px));font-size:calc(50% + (3px));font-size:calc(50% - (-3px));font-size:calc(50% - -3px)}which looks correct.
It seems the repo in charge of this is this fork https://github.com/BSI-Business-Systems-Integration-AG/yuicompressor
Aleuck commentedon Aug 23, 2020
This is not correct, @frangarcia
calc((50%)+(3px))Change parameters order to avoid YUI Compressor bug
Change parameters order to avoid YUI Compressor bug (#1680)
Avoid using calc(A + Npx) to circumvent bug in a CSS compressor
Avoid using calc(A + Npx) to circumvent bug in a CSS compressor
Fix bug 1692423: Replace broken CSS compressor with a no-op compressor
R-W-C commentedon Sep 28, 2022
September 2022 and still broken.
Version 2.4.8 has got several bugs. One of them is described here: https://stackoverflow.com/a/19339287/760777
Version 2.4.9 has never been released.
So back to version 2.4.7
There is the calc bug. Just use the double minus solution.
So
left: calc(100% + 14px);
becomes
left: calc(100 - -14px); /* + replaced with - - because of yuicompressor bug */