From 453bbe42b9255b03797a6a1a1f7541b5924dfd40 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Wed, 19 Dec 2012 22:05:52 +0100 Subject: [PATCH] Fixed issue #37 - converting 'white' and other colors in class names. --- lib/clean.js | 2 +- test/unit-test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/clean.js b/lib/clean.js index 0f462c67..bf6a4d8c 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -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); }); diff --git a/test/unit-test.js b/test/unit-test.js index 12d33d85..4f9080b4 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -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}' -- 2.34.1