Fixed issue #37 - converting 'white' and other colors in class names.
authorGoalSmashers <jakub@goalsmashers.com>
Wed, 19 Dec 2012 21:05:52 +0000 (22:05 +0100)
committerGoalSmashers <jakub@goalsmashers.com>
Wed, 19 Dec 2012 21:05:52 +0000 (22:05 +0100)
lib/clean.js
test/unit-test.js

index 0f462c6..bf6a4d8 100644 (file)
@@ -169,7 +169,7 @@ var CleanCSS = {
       var colorSwitcher = function(match, prefix, colorValue, suffix) {
         return prefix + CleanCSS.colors[type][colorValue] + suffix;
       };
-      replace(new RegExp("(.)" + pattern + "([;\\}!\\) ])", 'g'), colorSwitcher);
+      replace(new RegExp("([ :,\(])" + pattern + "([;\\}!\\) ])", 'g'), colorSwitcher);
       replace(new RegExp("(,)" + pattern + "(,)", 'g'), colorSwitcher);
     });
 
index 12d33d8..4f9080b 100644 (file)
@@ -392,6 +392,10 @@ vows.describe('clean-units').addBatch({
       'a{color:white;border-color:black;background-color:fuchsia}p{background:yellow}',
       'a{color:#fff;border-color:#000;background-color:#f0f}p{background:#ff0}'
     ],
+    'keep selectors with color name #1': ".black-and-white .foo{color:#fff;background-color:#000}",
+    'keep selectors with color name #2': ".go-blues{background:#000}",
+    'keep selectors with color name #3': "#top_white{background:#000}",
+    'keep selectors with color name #4': "a[data-sth=white]{background:#000}",
     'color names to hex values with important': [
       'a{color:white !important}',
       'a{color:#fff!important}'