-
Notifications
You must be signed in to change notification settings - Fork 664
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
YUI Compressor is breaking some CSS, specifically calc(100% + ##px) #59
Comments
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. Examples: Does anybody know a workaround for this? I see no other option but to exclude this part of the CSS from Jammit's pipeline. |
I'm having the same issue. Although |
Same here! Vote for this! |
Me too. |
Same problem troubled me |
gets compressed as:
i currently have to add a space after the - before the inner expression.
i have to do this every time i commit css-related changes. |
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); |
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? |
We had fixed this in our local version, I just forgot to commit it back for upstream pull request #107 |
great! let us know when the merge has been approved / is complete? |
The PR breaks the build, but it's a huge step forward. Thanks, @djgilcrease! |
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. |
See the Travis status on #107 Or just check the build: https://travis-ci.org/yui/yuicompressor/builds/11968385 |
not familiar with 'checking the build' but i see that it "failed" ? |
This will likely be part of 2.4.9, unless there's a strong objection from the user community. |
What's the ETA on 2.4.9? |
Ok, will get the build passing again |
Build is passing for pull request #107 again https://travis-ci.org/yui/yuicompressor/builds/11977764 |
Can we get this merged please? Looks like it's ready to go. |
Just checking on the status of this since the build tests have been passing for 4 months now |
Any update on this? |
One nice option: use simple math and do a double negative. The bug doesn't seem to affect the Replace this: width: calc(100% + 20px) With this: width: calc(100% - -20px); |
interesting (?) workaround -- supported by all browsers? |
it is, but it does not fix multiplication or division issues |
facing same issue Team, Please fix it or tell me how can i fix it without (- -) solution |
Compression examples:
|
Before compression spaces are there .file-item{width:calc(100vw - 40px);height:calc(((100vw - 40px) * .73)+40px)} |
Any news on this? YUI Compressor breaks CSS calc for 5 years! |
@sunnybear agree with you. 5 years done. And, still I faced the issue "+" then again i replace it with calc(x - - y). :D |
Does anybody have a list of issues with calc? We've faced with |
@beaktor |
See yui/yuicompressor#59 The spec mandates spaces around ‘+’ and ‘-’. Chrome is lax on that rule tho, but Firefox (and possibly others) ain’t!
it's yui compressor still mantained? |
Using YuiCompressor 2.4.8 and the bug is still on. |
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:
this output was generated:
which looks correct. It seems the repo in charge of this is this fork https://github.com/BSI-Business-Systems-Integration-AG/yuicompressor |
This is not correct, @frangarcia |
The previous code lead to an invalid value for the left property: `left: calc(-50vw+50%);` This was being caused due to a bug in YUI Compressor. You can read a detailed explanation about it in this issue: yui/yuicompressor#59 This is fixed since version 2.4.9-BSI-2. But, until we don't update prod's YUI Compressor, this PR work as a bugfix since it changes the parameters order to one properly understood by the bugged version. More aboute this in this issue comment: yui/yuicompressor#59 (comment)
The previous code lead to an invalid value for the left property: `left: calc(-50vw+50%);` This was being caused due to a bug in YUI Compressor. You can read a detailed explanation about it in this issue: yui/yuicompressor#59 This is fixed since version 2.4.9-BSI-2. But, until we don't update prod's YUI Compressor, this PR work as a bugfix since it changes the parameters order to one properly understood by the bugged version. More aboute this in this issue comment: yui/yuicompressor#59 (comment)
The + and - operators in CSS calc() must be surrounded by whitespace: https://developer.mozilla.org/en-US/docs/Web/CSS/calc()#notes The yuglify CSS compressor we use removes them and breaks CSS. I tried yuicompressor instead, which has the same bug: yui/yuicompressor#59 Other CSS compressors I've checked look (even more) outdated. I haven't tested any. The only other instance of calc() in our code uses - instead of +, which is fine.
The + and - operators in CSS calc() must be surrounded by whitespace: https://developer.mozilla.org/en-US/docs/Web/CSS/calc()#notes The yuglify CSS compressor we use removes them and breaks CSS. I tried yuicompressor instead, which has the same bug: yui/yuicompressor#59 Other CSS compressors I've checked look (even more) outdated. I haven't tested any. The only other instance of calc() in our code uses - instead of +, which is fine.
Our default CSS compressor removes whitespace around + and - in calc(), which are significant: https://developer.mozilla.org/en-US/docs/Web/CSS/calc()#notes None of the CSS compressors seems to be prone to this bug, here's another: yui/yuicompressor#59 We shouldn't constrain our CSS by bugs in that pipeline. Instead, let's use a no-op css compressor to cat the files together.
September 2022 and still broken. So back to version 2.4.7 So left: calc(100% + 14px); becomes left: calc(100 - -14px); /* + replaced with - - because of yuicompressor bug */ |
turns into
.issue-59{width:100%;width:-webkit-calc(100%+30px);width:-moz-calc(100%+30px);width:calc(100%+30px)}
instead of
.issue-59{width:100%;width:-webkit-calc(100% + 30px);width:-moz-calc(100% + 30px);width:calc(100% + 30px)}
Notice the missing spaces
The text was updated successfully, but these errors were encountered: