From: Jakub Pawlowicz Date: Sun, 27 Nov 2011 08:54:58 +0000 (+0100) Subject: Fixed issue with cleaning up spaces inside calc/-moz-calc declarations. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=5e56238e826b0292dafe511f78e7d31aaddc2e03;p=clean-css.git Fixed issue with cleaning up spaces inside calc/-moz-calc declarations. --- diff --git a/lib/clean.js b/lib/clean.js index 39ae837b..396bc393 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -114,7 +114,10 @@ var CleanCSS = { replace(/ {/g, '{') // whitespace before definition replace(/\} /g, '}') // whitespace after definition - // Get the special comments && content back + // Get the special comments, content content, and spaces inside calc back + replace(/calc\((.+)\)([;\}\w])/, function(match) { + return match.replace(/\+/g, ' + '); + }); replace(/__CSSCOMMENT__/g, function() { return specialComments.shift(); }); replace(/__CSSCONTENT__/g, function() { return contentBlocks.shift(); }); diff --git a/test/unit-test.js b/test/unit-test.js index 659a23ad..1f528527 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -78,6 +78,22 @@ vows.describe('clean-units').addBatch({ 'at end': [ 'a{color:#fff } ', 'a{color:#fff}' + ], + 'not inside calc method #1': [ + 'a{width:-moz-calc(100% - 1em);width:calc(100% - 1em)}', + 'a{width:-moz-calc(100% - 1em);width:calc(100% - 1em)}' + ], + 'not inside calc method #2': [ + 'div{margin:-moz-calc(50% + 15px) -moz-calc(50% + 15px);margin:calc(50% + .5rem) calc(50% + .5rem)}', + 'div{margin:-moz-calc(50% + 15px) -moz-calc(50% + 15px);margin:calc(50% + .5rem) calc(50% + .5rem)}' + ], + 'not inside calc method with more parentheses': [ + 'div{height:-moz-calc((10% + 12px)/2 + 10em)}', + 'div{height:-moz-calc((10% + 12px)/2 + 10em)}' + ], + 'not inside calc method with multiplication': [ + 'div{height:-moz-calc(3 * 2em + 10px)}', + 'div{height:-moz-calc(3 * 2em + 10px)}' ] }), 'empty elements': cssContext({