Fixes #496 - space after bracket removal inside `calc`.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 16 Mar 2015 18:52:29 +0000 (18:52 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 16 Mar 2015 20:10:25 +0000 (20:10 +0000)
In case of `) -` and `) +` in `calc` expressions a space should not
be removed at all times.

History.md
lib/selectors/optimizers/simple.js
test/integration-test.js

index 1f9e3d2..4bceb22 100644 (file)
@@ -7,6 +7,11 @@
 * Fixed issue [#396](https://github.com/jakubpawlowicz/clean-css/issues/396) - better input source maps tracking.
 * Fixed issue [#480](https://github.com/jakubpawlowicz/clean-css/issues/480) - extracting uppercase property names.
 
+[3.1.7 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.6...3.1)
+==================
+
+* Fixes issue [#496](https://github.com/jakubpawlowicz/clean-css/issues/496) - space after bracket removal.
+
 [3.1.6 / 2015-03-12](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.5...v3.1.6)
 ==================
 
index b221c31..a9bd64d 100644 (file)
@@ -176,10 +176,10 @@ function colorMininifier(property, value, compatibility) {
 }
 
 function spaceMinifier(property, value) {
-  if (property == 'filter' || processable.implementedFor.test(property))
+  if (property == 'filter' || value.indexOf(') ') == -1 || processable.implementedFor.test(property))
     return value;
 
-  return value.replace(/\) /g, ')');
+  return value.replace(/\) ((?![\+\-] )|$)/g, ')$1');
 }
 
 function reduce(body, options) {
index 503b4eb..ce740df 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))}'
     ],
+    'not inside calc method with brackets #2': [
+      'body{width:calc((978px * 2/3) - 30px)}',
+      'body{width:calc((978px * 2/3) - 30px)}'
+    ],
     'with space between braces': [
       'body{width:calc( ( 100% - 12px) / 3 )}',
       'body{width:calc((100% - 12px)/ 3)}'