Added striping quotation from @keyframes declaration.
authorGoalSmashers <jakub@goalsmashers.com>
Sat, 8 Dec 2012 13:33:19 +0000 (13:33 +0000)
committerGoalSmashers <jakub@goalsmashers.com>
Sat, 8 Dec 2012 13:33:19 +0000 (13:33 +0000)
lib/clean.js
test/unit-test.js

index 52a893e..97d6b5c 100644 (file)
@@ -123,6 +123,12 @@ var CleanCSS = {
       return propertyName + ':' + fontDef.replace(/['"]([\w\-]+)['"]/g, '$1');
     });
 
+    // strip quotation in @keyframes
+    replace(/@(\-moz\-|\-o\-|\-webkit\-)?keyframes ([^{]+)/g, function(match, prefix, name) {
+      prefix = prefix || '';
+      return '@' + prefix + 'keyframes ' + (name.indexOf(' ') > -1 ? name : name.replace(/['"]/g, ''));
+    });
+
     // rgb to hex colors
     replace(/rgb\s*\(([^\)]+)\)/g, function(match, color) {
       var parts = color.split(',');
index b87a565..17f7a52 100644 (file)
@@ -497,6 +497,21 @@ vows.describe('clean-units').addBatch({
       "a{font:12px/16px Helvetica-Regular,Arial-Bold}"
     ]
   }),
+  'animations': cssContext({
+    'shorten': [
+      '@keyframes test\n{ from\n { width:100px; }\n to { width:200px; }\n}',
+      '@keyframes test{from{width:100px}to{width:200px}}'
+    ],
+    'remove name quotes': [
+      "@keyframes \"test1\"{}@keyframes 'test2'{}",
+      "@keyframes test1{}@keyframes test2{}"
+    ],
+    'not remove name quotes if whitespace inside': "@keyframes \"test 1\"{}@keyframes 'test 2'{}",
+    'remove name quotes for vendor prefixes': [
+      "@-moz-keyframes 'test'{}@-o-keyframes 'test'{}@-webkit-keyframes 'test'{}",
+      "@-moz-keyframes test{}@-o-keyframes test{}@-webkit-keyframes test{}"
+    ]
+  }),
   'ie filters': cssContext({
     'short alpha': [
       "a{ filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=80); -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)';}",