Fixes #472 - broken function minification.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 4 Mar 2015 10:10:17 +0000 (10:10 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 4 Mar 2015 10:27:47 +0000 (10:27 +0000)
There was a wrong tokenization inside functions (gradient) with
functions (rgb) inside them.

History.md
lib/utils/extractors.js
test/source-map-test.js

index b75a7e3..5b3aa10 100644 (file)
@@ -6,6 +6,7 @@
 [3.1.4 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.3...3.1)
 ==================
 
+* Fixes issue [#472](https://github.com/jakubpawlowicz/clean-css/issues/472) - broken function minification.
 * Fixes issue [#477](https://github.com/jakubpawlowicz/clean-css/issues/477) - `@import`s order in restructuring.
 * Fixes issue [#478](https://github.com/jakubpawlowicz/clean-css/issues/478) - ultimate fix to brace whitespace.
 
index 64d54f7..824f179 100644 (file)
@@ -22,7 +22,7 @@ var Extractors = {
     var addSourceMap = context.addSourceMap;
 
     if (string.replace && string.indexOf(')') > 0)
-      string = string.replace(/\)([^\s_;:,])/g, context.addSourceMap ? ') __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__$1' : ') $1');
+      string = string.replace(/\)([^\s_;:,\)])/g, context.addSourceMap ? ') __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__$1' : ') $1');
 
     for (var i = 0, l = string.length; i < l; i++) {
       current = string[i];
index a46d69b..a3006ab 100644 (file)
@@ -22,6 +22,12 @@ vows.describe('source-map')
       'gets right output': function (minified) {
         assert.equal(minified.styles, 'html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}');
       }
+    },
+    'background gradient': {
+      'topic': new CleanCSS({ sourceMap: true }).minify('a{background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 0, rgba(0, 0, 0, 0.1))}'),
+      'gets right output': function (minified) {
+        assert.equal(minified.styles, 'a{background:linear-gradient(to bottom,rgba(0,0,0,.1) 0,rgba(0,0,0,.1))}');
+      }
     }
   })
   .addBatch({