Fixes #511 - calc, parentheses and advanced optimizations.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 4 Apr 2015 07:18:24 +0000 (08:18 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 4 Apr 2015 08:16:48 +0000 (09:16 +0100)
We're waiting for #429 to have it fixed properly, but here's an
intermediate fix.

History.md
lib/properties/token.js
test/integration-test.js

index 6f3e919..86c2577 100644 (file)
@@ -9,6 +9,11 @@
 * Fixed issue [#397](https://github.com/jakubpawlowicz/clean-css/issues/397) - support for source map sources.
 * Fixed issue [#480](https://github.com/jakubpawlowicz/clean-css/issues/480) - extracting uppercase property names.
 
+[3.1.9 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.8...3.1)
+==================
+
+* Fixes issue [#511](https://github.com/jakubpawlowicz/clean-css/issues/511) - `)` advanced processing.
+
 [3.1.8 / 2015-03-17](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.7...v3.1.8)
 ==================
 
index 2d030e3..102f9b8 100644 (file)
@@ -133,7 +133,7 @@ module.exports = (function() {
           t.prop + ':' + t.value + (t.isImportant ? important : '');
 
         // FIXME: to be fixed with #429
-        property = property.replace(/\) /g, ')');
+        property = property.replace(/\) ([^\+\-\/\*])/g, ')$1');
 
         list.push([property]);
       }
index ce740df..54371da 100644 (file)
@@ -140,6 +140,10 @@ vows.describe('integration tests').addBatch({
       'body{width:calc((978px * 2/3) - 30px)}',
       'body{width:calc((978px * 2/3) - 30px)}'
     ],
+    'not inside calc method with brackets #3': [
+      'body{margin:calc(99.99% * 1/3 - (30px - 30px * 1/3) + 30px)}',
+      'body{margin:calc(99.99% * 1/3 - (30px - 30px * 1/3) + 30px)}'
+    ],
     'with space between braces': [
       'body{width:calc( ( 100% - 12px) / 3 )}',
       'body{width:calc((100% - 12px)/ 3)}'