Fixes #534 - wrong block stringifying.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 20 Apr 2015 06:40:41 +0000 (07:40 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 20 Apr 2015 06:54:24 +0000 (07:54 +0100)
Flat blocks (`@font-face`) were omitted when adding optimization metadata,
thus an important attribute was incorrectly added.

History.md
lib/selectors/optimization-metadata.js
test/selectors/optimization-metadata-test.js
test/source-map-test.js

index 6adba11..0551b8b 100644 (file)
@@ -3,6 +3,11 @@
 
 * Fixed issue [#436](https://github.com/jakubpawlowicz/clean-css/issues/436) - refactors URI rewriting.
 
+[3.2.1 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.0...3.2)
+==================
+
+* Fixed issue [#534](https://github.com/jakubpawlowicz/clean-css/issues/534) - wrong `@font-face` stringifying.
+
 [3.2.0 / 2015-04-19](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.9...v3.2.0)
 ==================
 
index d5b469e..a0b27a8 100644 (file)
@@ -10,6 +10,7 @@ function addOptimizationMetadata(tokens) {
     var token = tokens[i];
 
     switch (token[0]) {
+      case 'flat-block':
       case 'selector':
         addToProperties(token[2]);
         break;
index 15907b3..fec289c 100644 (file)
@@ -26,6 +26,13 @@ vows.describe(addOptimizationMetadata)
         assert.deepEqual(tokens, [['selector', ['a'], [[['color', true, false], ['red']]] ]]);
       }
     },
+    'flat block': {
+      'topic': [['flat-block', ['@font-face'], [[['font-family'], ['x']]] ]],
+      'metadata': function (tokens) {
+        addOptimizationMetadata(tokens);
+        assert.deepEqual(tokens, [['flat-block', ['@font-face'], [[['font-family', false, false], ['x']]] ]]);
+      }
+    },
     'underscore hack': {
       'topic': [['selector', ['a'], [[['_color'], ['red']]] ]],
       'metadata': function (tokens) {
index da4318b..ec6c8f0 100644 (file)
@@ -34,6 +34,14 @@ vows.describe('source-map')
       '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))}');
       }
+    },
+    'important': {
+      'topic': function () {
+        return new CleanCSS({ sourceMap: true }).minify('@font-face{font-family:si}a{font-family:si!important}');
+      },
+      'gets right output': function (minified) {
+        assert.equal(minified.styles, '@font-face{font-family:si}a{font-family:si!important}');
+      }
     }
   })
   .addBatch({