Adds simplified comments processing & imports.
authorGoalSmashers <jakub@goalsmashers.com>
Fri, 6 Sep 2013 07:24:27 +0000 (09:24 +0200)
committerGoalSmashers <jakub@goalsmashers.com>
Fri, 6 Sep 2013 07:25:46 +0000 (09:25 +0200)
History.md
lib/clean.js
test/unit-test.js

index 8ec4005..b61db1a 100644 (file)
@@ -10,6 +10,7 @@
 * Fixed issue [#130](https://github.com/GoalSmashers/clean-css/issues/130) - better code modularity.
 * Fixed issue [#135](https://github.com/GoalSmashers/clean-css/issues/135) - require node.js 0.8+.
 * Renamed lib's `debug` option to `benchmark` when doing per-minification benchmarking.
+* Added simplified comments processing & imports.
 
 1.0.12 / 2013-07-19
 ===================
index 20bb693..e8f1ff5 100644 (file)
@@ -63,17 +63,6 @@ var CleanCSS = {
     var urlsProcessor = new UrlsProcessor();
     var importInliner = new ImportInliner();
 
-    var removeComments = function() {
-      replace(function escapeComments() {
-        data = commentsProcessor.escape(data);
-      });
-    };
-
-    removeComments();
-
-    // replace all escaped line breaks
-    replace(/\\(\r\n|\n)/mg, '');
-
     if (options.processImport) {
       // inline all imports
       replace(function inlineImports() {
@@ -82,12 +71,15 @@ var CleanCSS = {
           relativeTo: options.relativeTo
         });
       });
-
-      // strip comments with inlined imports
-      if (data.indexOf('/*') > -1)
-        removeComments();
     }
 
+    replace(function escapeComments() {
+      data = commentsProcessor.escape(data);
+    });
+
+    // replace all escaped line breaks
+    replace(/\\(\r\n|\n)/mg, '');
+
     // 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)
index 2348035..49e1776 100644 (file)
@@ -960,7 +960,7 @@ title']",
       ".five{background:url(data:image/jpeg;base64,/9j/)}"
     ],
     'inside a comment': [
-      '/* @import */a { color: red; }',
+      '/* @import url(test/data/partials/five.css); */a { color: red; }',
       'a{color:red}'
     ],
     'of a file with a comment': [