From: Jakub Pawlowicz Date: Fri, 24 Apr 2015 07:47:02 +0000 (+0100) Subject: Fixes #546 - IE<11 `calc()` issue. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=69686ef0f2db092bd513c49b4ef5e1cd830af02e;p=clean-css.git Fixes #546 - IE<11 `calc()` issue. So IE<11 does not support a space between calc() and whatever comes after it. There's gonna be a follow up with #547 in 3.3. --- diff --git a/History.md b/History.md index 2742310a..4c2fadbe 100644 --- a/History.md +++ b/History.md @@ -13,6 +13,7 @@ ================== * Fixed issue [#544](https://github.com/jakubpawlowicz/clean-css/issues/544) - regression in same value merging. +* Fixed issue [#546](https://github.com/jakubpawlowicz/clean-css/issues/546) - IE<11 `calc()` issue. [3.2.3 / 2015-04-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.2...v3.2.3) ================== diff --git a/lib/stringifier/helpers.js b/lib/stringifier/helpers.js index ffb6b816..8c2a244b 100644 --- a/lib/stringifier/helpers.js +++ b/lib/stringifier/helpers.js @@ -17,6 +17,10 @@ function afterClosingBrace(token, valueIndex) { return token[valueIndex][0][token[valueIndex][0].length - 1] == ')' || token[valueIndex][0].indexOf('__ESCAPED_URL_CLEAN_CSS') === 0; } +function afterCalc(token, valueIndex) { + return token[valueIndex][0].indexOf('calc(') === 0; +} + function afterComma(token, valueIndex) { return token[valueIndex][0] == ','; } @@ -38,7 +42,7 @@ function inFilter(token) { } function inSpecialContext(token, valueIndex, context) { - return !context.spaceAfterClosingBrace && afterClosingBrace(token, valueIndex) || + return !context.spaceAfterClosingBrace && afterClosingBrace(token, valueIndex) && !afterCalc(token, valueIndex) || beforeSlash(token, valueIndex) || afterSlash(token, valueIndex) || beforeComma(token, valueIndex) || diff --git a/test/integration-test.js b/test/integration-test.js index 84de7b21..a7fdce0a 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -161,15 +161,15 @@ vows.describe('integration tests').addBatch({ 'after hsla': 'a{text-shadow:hsla(240,100%,40%,.5)-1px 1px}', 'inside background': [ 'a{background:calc(100% - 2px) 10px no-repeat}', - 'a{background:calc(100% - 2px)10px no-repeat}' + 'a{background:calc(100% - 2px) 10px no-repeat}' ], 'inside background with fraction unit': [ - 'a{background:calc(100% - 2px).5em no-repeat}', - 'a{background:calc(100% - 2px).5em no-repeat}' + 'a{background:calc(100% - 2px) .5em no-repeat}', + 'a{background:calc(100% - 2px) .5em no-repeat}' ], 'inside margin': [ 'a{margin:calc(100% - 2px) calc(100% - 5px)}', - 'a{margin:calc(100% - 2px)calc(100% - 5px)}' + 'a{margin:calc(100% - 2px) calc(100% - 5px)}' ], 'after :not #1': [ 'li:not(.foo).bar{color:red}', @@ -629,7 +629,7 @@ vows.describe('integration tests').addBatch({ ], 'negative padding in calculations': [ 'div{padding:calc(100% - 5px) 0 0 0}', - 'div{padding:calc(100% - 5px)0 0}' + 'div{padding:calc(100% - 5px) 0 0}' ] }), 'floats': cssContext({ @@ -2011,7 +2011,7 @@ title']{display:block}", 'background position': cssContext({ 'calc as a value': [ '*{background:white calc(100% - 10px) center no-repeat;background-image:url(test.png)}', - '*{background:calc(100% - 10px)center no-repeat #fff;background-image:url(test.png)}' + '*{background:calc(100% - 10px) center no-repeat #fff;background-image:url(test.png)}' ] }), 'background-clip': cssContext({ diff --git a/test/selectors/optimizer-test.js b/test/selectors/optimizer-test.js index 0390840f..e5fc14bf 100644 --- a/test/selectors/optimizer-test.js +++ b/test/selectors/optimizer-test.js @@ -232,6 +232,10 @@ vows.describe(SelectorsOptimizer) 'whitespace body': [ 'a{ \n }', '' + ], + 'whitespace after calc()': [ + 'div{margin:calc(100% - 20px) 1px}', + 'div{margin:calc(100% - 20px) 1px}' ] }) )