From cf88fd011dd893f04f5c93615c1c3d8e80a1ac74 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Sat, 30 Mar 2013 17:02:57 +0100 Subject: [PATCH] Follow up to #86 - removing extra space after removed comment. --- lib/clean.js | 2 +- test/unit-test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/clean.js b/lib/clean.js index c40642fd..719864d3 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -322,7 +322,7 @@ var CleanCSS = { var specialCommentsCount = context.specialComments.length; var breakSuffix = options.keepBreaks ? lineBreak : ''; - replace(new RegExp('__CSSCOMMENT__(' + lineBreak + ')?', 'g'), function() { + replace(new RegExp('__CSSCOMMENT__(' + lineBreak + '| )?', 'g'), function() { switch (options.keepSpecialComments) { case '*': return context.specialComments.shift() + breakSuffix; diff --git a/test/unit-test.js b/test/unit-test.js index 6de079d6..67d12277 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -238,6 +238,10 @@ vows.describe('clean-units').addBatch({ 'strip all': [ '/*! important comment */a{color:red}/* some comment *//*! important comment */', 'a{color:red}' + ], + 'move charset before': [ + "/*! some comment */" + lineBreak + lineBreak + "@charset 'utf-8';" + lineBreak + lineBreak + "a{}", + "@charset 'utf-8';a{}" ] }, { keepSpecialComments: 0 }), 'text content': cssContext({ -- 2.34.1