Fixed expanding + signs in calc() when mixed up with adjacent (+) selector.
authorJakub Pawlowicz <jakub@goalsmashers.com>
Sun, 27 Nov 2011 15:01:02 +0000 (16:01 +0100)
committerJakub Pawlowicz <jakub@goalsmashers.com>
Sun, 27 Nov 2011 15:01:02 +0000 (16:01 +0100)
lib/clean.js
test/unit-test.js

index 425b343..0bc0dfe 100644 (file)
@@ -115,7 +115,7 @@ var CleanCSS = {
     replace(/\} /g, '}') // whitespace after definition
     
     // Get the special comments, content content, and spaces inside calc back
-    replace(/calc\((.+)\)([;\}\w])/, function(match) {
+    replace(/calc\([^\}]+\}/g, function(match) {
       return match.replace(/\+/g, ' + ');
     });
     replace(/__CSSCOMMENT__/g, function() { return specialComments.shift(); });
index be02e8d..59b2fa9 100644 (file)
@@ -131,6 +131,10 @@ vows.describe('clean-units').addBatch({
     'not strip standalone universal selector': [
       'label ~ * + span',
       'label~*+span'
+    ],
+    'not expand + in selectors mixed with calc methods': [
+      'div{width:calc(50% + 3em)}div + div{width:100%}div:hover{width:calc(50% + 4em)}* > div {border:1px solid #f0f}',
+      'div{width:calc(50% + 3em)}div+div{width:100%}div:hover{width:calc(50% + 4em)}*>div{border:1px solid #f0f}'
     ]
   }),
   'comments': cssContext({