Fixes #208 - fixes swallowing `@viewport`, `@page`, and `@supports` when doing advanc...
authorGoalSmashers <jakub@goalsmashers.com>
Thu, 16 Jan 2014 22:20:24 +0000 (22:20 +0000)
committerGoalSmashers <jakub@goalsmashers.com>
Thu, 16 Jan 2014 22:33:46 +0000 (22:33 +0000)
History.md
lib/selectors/tokenizer.js
test/unit-test.js

index b1539f9..938ec18 100644 (file)
 * Fixed issue [#186](https://github.com/GoalSmashers/clean-css/issues/186) - strip unit from 0rem.
 * Fixed issue [#207](https://github.com/GoalSmashers/clean-css/issues/207) - bug in parsing protocol `@import`s.
 
+[2.0.7 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.0.6...v2.0.7)
+==================
+
+* Fixed issue [#208](https://github.com/GoalSmashers/clean-css/issues/208) - don't swallow @page and @viewport.
+
 [2.0.6 / 2014-01-04](https://github.com/GoalSmashers/clean-css/compare/v2.0.5...v2.0.6)
 ==================
 
index a7f09b0..ec671b7 100644 (file)
@@ -3,6 +3,7 @@
 module.exports = function Tokenizer(data, minifyContext) {
   var chunker = new Chunker(data, 128);
   var chunk = chunker.next();
+  var flatBlock = /^@(font\-face|page|\-ms\-viewport|\-o\-viewport|viewport)/;
 
   var whatsNext = function(context) {
     var cursor = context.cursor;
@@ -82,7 +83,7 @@ module.exports = function Tokenizer(data, minifyContext) {
           nextEnd = chunk.indexOf('{', nextSpecial + 1);
           var block = chunk.substring(context.cursor, nextEnd).trim();
 
-          var isFlat = fragment.indexOf('@font-face') === 0;
+          var isFlat = flatBlock.test(block);
           oldMode = context.mode;
           context.cursor = nextEnd + 1;
           context.mode = isFlat ? 'body' : 'block';
index d653722..78c251f 100644 (file)
@@ -1448,5 +1448,14 @@ title']{display:block}",
       'a{border-top:1px solid red;border-top-color:#0f0;color:red;border-top-width:2px;border-bottom-width:1px;border:0;border-left:1px solid red}',
       'a{color:red;border:0;border-left:1px solid red}'
     ]
+  }),
+  'grouping with advanced optimizations': cssContext({
+    '@-moz-document': '@-moz-document domain(mozilla.org){a{color:red}}',
+    '@media': '@media{a{color:red}}',
+    '@page': '@page{margin:.5em}',
+    '@supports': '@supports (display:flexbox){.flex{display:flexbox}}',
+    '@-ms-viewport': '@-ms-viewport{width:device-width}',
+    '@-o-viewport': '@-o-viewport{width:device-width}',
+    '@viewport': '@viewport{width:device-width}'
   })
 }).export(module);