Adds longer escape markers to speed up searching.
authorGoalSmashers <jakub@goalsmashers.com>
Mon, 30 Sep 2013 14:58:34 +0000 (16:58 +0200)
committerGoalSmashers <jakub@goalsmashers.com>
Sat, 2 Nov 2013 16:30:11 +0000 (17:30 +0100)
lib/text/comments.js
lib/text/escape-store.js
lib/text/expressions.js
lib/text/free.js
lib/text/urls.js
test/unit-test.js

index 7528b75..5667e7e 100644 (file)
@@ -1,10 +1,10 @@
 var EscapeStore = require('./escape-store');
 
 module.exports = function Comments(keepSpecialComments, keepBreaks, lineBreak) {
-  var comments = new EscapeStore('CSSCOMMENT');
+  var comments = new EscapeStore('COMMENT');
 
   return {
-    // Strip special comments (/*! ... */) by replacing them by __CSSCOMMENT__ marker
+    // Strip special comments (/*! ... */) by replacing them by a special marker
     // for further restoring. Plain comments are removed. It's done by scanning data using
     // String#indexOf scanning instead of regexps to speed up the process.
     escape: function(data) {
index a4fded8..8c2f07f 100644 (file)
@@ -1,4 +1,6 @@
 module.exports = function EscapeStore(placeholderRoot) {
+  placeholderRoot = 'ESCAPED_' + placeholderRoot + '_CLEAN_CSS';
+
   var placeholderToData = {};
   var dataToPlaceholder = {};
   var count = 0;
index 948ef0e..2ca193b 100644 (file)
@@ -34,7 +34,7 @@ module.exports = function Expressions() {
   };
 
   return {
-    // Escapes expressions by replacing them by the __EXPRESSION__
+    // Escapes expressions by replacing them by a special
     // marker for further restoring. It's done via string scanning
     // instead of regexps to speed up the process.
     escape: function(data) {
index c66c403..eb0f057 100644 (file)
@@ -1,7 +1,7 @@
 var EscapeStore = require('./escape-store');
 
 module.exports = function Free() {
-  var texts = new EscapeStore('CSSFREETEXT');
+  var texts = new EscapeStore('FREE_TEXT');
 
   var findNonEscapedEnd = function(data, matched, start) {
     var end = start;
@@ -20,7 +20,7 @@ module.exports = function Free() {
   };
 
   return {
-    // Strip content tags by replacing them by the __CSSFREETEXT__
+    // Strip content tags by replacing them by the a special
     // marker for further restoring. It's done via string scanning
     // instead of regexps to speed up the process.
     escape: function(data) {
index 669352a..007e41d 100644 (file)
@@ -4,7 +4,7 @@ module.exports = function Urls() {
   var urls = new EscapeStore('URL');
 
   return {
-    // Strip urls by replacing them by the __URL__
+    // Strip urls by replacing them by a special
     // marker for further restoring. It's done via string scanning
     // instead of regexps to speed up the process.
     escape: function(data) {
index 17eb951..3c7a88b 100644 (file)
@@ -648,7 +648,7 @@ vows.describe('clean-units').addBatch({
     'keep urls from being stripped down #1': 'a{background:url(/image-1.0.png)}',
     'keep urls from being stripped down #2': "a{background:url(/image-white.png)}",
     'keep urls from being stripped down #3': "a{background:#eee url(/libraries/jquery-ui-1.10.1.custom/images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x}",
-    'keep __URL__ in comments (so order is important)': '/*! __URL__ */a{display:block}',
+    'keep special markers in comments (so order is important)': '/*! __ESCAPED_URL_CLEAN_CSS0__ */a{display:block}',
     'strip new line in urls': [
       'a{background:url(/very/long/\
 path)}',