Fixes #455 - whitespace between braces.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 7 Feb 2015 12:16:07 +0000 (12:16 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 7 Feb 2015 12:44:11 +0000 (12:44 +0000)
`( (` was handled incorrectly as the first brace got removed.

History.md
lib/utils/extractors.js
test/integration-test.js

index abbd3e2..507093d 100644 (file)
@@ -19,6 +19,7 @@
 ==================
 
 * Fixed issue [#453](https://github.com/jakubpawlowicz/clean-css/issues/453) - double `background-repeat`.
+* Fixed issue [#455](https://github.com/jakubpawlowicz/clean-css/issues/455) - property extracting regression.
 
 [3.0.9 / 2015-02-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.8...v3.0.9)
 ==================
index e19c768..0cc7870 100644 (file)
@@ -14,6 +14,7 @@ var Extractors = {
     var isSpecial;
     var wasSpecial;
     var current;
+    var last;
     var secondToLast;
     var wasCloseParenthesis;
     var isEscape;
@@ -66,8 +67,9 @@ var Extractors = {
         isSpecial = current === ':' || current === '[' || current === ']' || current === ',' || current === '(' || current === ')';
 
         if (wasWhitespace && isSpecial) {
+          last = buffer[buffer.length - 1];
           secondToLast = buffer[buffer.length - 2];
-          if (secondToLast != '+' && secondToLast != '-' && secondToLast != '/' && secondToLast != '*')
+          if (secondToLast != '+' && secondToLast != '-' && secondToLast != '/' && secondToLast != '*' && last != '(')
             buffer.pop();
           buffer.push(current);
         } else if (isWhitespace && wasSpecial && !wasCloseParenthesis) {
index 17f851f..d2eacb3 100644 (file)
@@ -136,6 +136,10 @@ vows.describe('integration tests').addBatch({
       'body{margin-left:calc(50vw + (1024px/2))}',
       'body{margin-left:calc(50vw + (1024px/2))}'
     ],
+    'with space between braces': [
+      'body{width:calc( ( 100% - 12px) / 3 )}',
+      'body{width:calc((100% - 12px)/ 3)}'
+    ],
     'before colon': [
       '#test{padding-left :0}',
       '#test{padding-left:0}'