From 6fe598fc4389d3b1dc091eade807c7fd4ace1710 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Sat, 8 Dec 2012 13:33:19 +0000 Subject: [PATCH] Added striping quotation from @keyframes declaration. --- lib/clean.js | 6 ++++++ test/unit-test.js | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/clean.js b/lib/clean.js index 52a893e6..97d6b5c6 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -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(','); diff --git a/test/unit-test.js b/test/unit-test.js index b87a5652..17f7a52c 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -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)';}", -- 2.34.1