From 14183554751f23c81409647eb5af2a29b4ad5b10 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Tue, 11 Jun 2013 13:09:14 +0200 Subject: [PATCH] Fixes issue #113 - @import inside comment statement. --- History.md | 5 +++++ lib/clean.js | 10 +++++----- test/unit-test.js | 4 ++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index ca4f72cb..3e5875f1 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +1.0.9 / 2013-06-xx +================== + +* Fixed issue [#113](https://github.com/GoalSmashers/clean-css/issues/113) - @import in comments. + 1.0.8 / 2013-06-10 ================== diff --git a/lib/clean.js b/lib/clean.js index eab99753..2af9486c 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -77,6 +77,11 @@ var CleanCSS = { // replace all escaped line breaks replace(/\\(\r\n|\n)/mg, ''); + // strip comments one by one + replace(function stripComments() { + data = CleanCSS._stripComments(context, data); + }); + // inline all imports replace(function inlineImports() { data = CleanCSS._inlineImports(data, { @@ -85,11 +90,6 @@ var CleanCSS = { }); }); - // strip comments one by one - replace(function stripComments() { - data = CleanCSS._stripComments(context, data); - }); - // strip parentheses in urls if possible (no spaces inside) replace(/url\((['"])([^\)]+)['"]\)/g, function(match, quote, url) { if (url.match(/[ \t]/g) !== null || url.indexOf('data:') === 0) diff --git a/test/unit-test.js b/test/unit-test.js index 2505cf93..56e866a6 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -833,6 +833,10 @@ title']", 'of a file with a resource URI': [ "@import url(test/data/partials/five.css);", ".five{background:url(data:image/jpeg;base64,/9j/)}" + ], + 'inside a comment': [ + '/* @import */a { color: red; }', + 'a{color:red}' ] }), '@import with absolute paths': cssContext({ -- 2.34.1