Fixes issue #117 - handling line break escaping in comments.
authorGoalSmashers <jakub@goalsmashers.com>
Mon, 8 Jul 2013 14:22:22 +0000 (16:22 +0200)
committerGoalSmashers <jakub@goalsmashers.com>
Mon, 8 Jul 2013 14:22:22 +0000 (16:22 +0200)
lib/clean.js
test/data/issue-117-snippet-min.css [new file with mode: 0644]
test/data/issue-117-snippet.css [new file with mode: 0644]
test/unit-test.js

index de6f989..11be0df 100644 (file)
@@ -80,11 +80,11 @@ var CleanCSS = {
       });
     };
 
+    removeComments();
+
     // replace all escaped line breaks
     replace(/\\(\r\n|\n)/mg, '');
 
-    removeComments();
-
     // inline all imports
     replace(function inlineImports() {
       data = CleanCSS._inlineImports(data, {
diff --git a/test/data/issue-117-snippet-min.css b/test/data/issue-117-snippet-min.css
new file mode 100644 (file)
index 0000000..66c0678
--- /dev/null
@@ -0,0 +1,3 @@
+@media only print{a,a:visited{text-decoration:underline}
+a[href]:after{content:" (" attr(href) ")"}
+abbr[title]:after{content:" (" attr(title) ")"}}
diff --git a/test/data/issue-117-snippet.css b/test/data/issue-117-snippet.css
new file mode 100644 (file)
index 0000000..39a47f4
--- /dev/null
@@ -0,0 +1,19 @@
+@media print, (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
+  /* Style adjustments for high resolution devices */
+}
+/**===================================================**\
+/**  PRINT STYLES
+/**===================================================**/
+@media only print {
+  a,
+  a:visited {
+    text-decoration: underline;
+  }
+  a[href]:after {
+    content: " (" attr(href) ")";
+  }
+  abbr[title]:after {
+    content: " (" attr(title) ")";
+  }
+  /** MANUALLY TRUNCATED FOR BREVITY **/
+}
index a965694..e2c7d8b 100644 (file)
@@ -226,6 +226,10 @@ vows.describe('clean-units').addBatch({
     'should remove comments with forward slashes inside': [
       '/*////*/a{color:red}',
       'a{color:red}'
+    ],
+    'should properly handle line breaks and ** characters inside comments': [
+      '/**====**\\\n/**2nd comment line/**===**/a{color:red}',
+      'a{color:red}'
     ]
   }),
   'important comments - one': cssContext({