Fixes #92 - uppercase colors to shortened version(s).
authorGoalSmashers <jakub@goalsmashers.com>
Fri, 29 Mar 2013 22:55:14 +0000 (23:55 +0100)
committerGoalSmashers <jakub@goalsmashers.com>
Fri, 29 Mar 2013 23:02:01 +0000 (00:02 +0100)
History.md
lib/clean.js
test/unit-test.js

index 175abe7..64c5689 100644 (file)
@@ -7,6 +7,7 @@
 * Fixed issue [#83](https://github.com/GoalSmashers/clean-css/issues/83) - HSL to hex color conversions.
 * Fixed issue [#2](https://github.com/GoalSmashers/clean-css/issues/2) - resolving `@import` rules.
 * Fixed issue [#80](https://github.com/GoalSmashers/clean-css/issues/80) - quotation in multi line strings.
+* Fixed issue [#92](https://github.com/GoalSmashers/clean-css/issues/92) - uppercase hex to short versions.
 
 0.10.2 / 2013-03-19
 ==================
index dc1aec2..9ae2efa 100644 (file)
@@ -208,10 +208,10 @@ var CleanCSS = {
     ['toHex', 'toName'].forEach(function(type) {
       var pattern = "(" + Object.keys(CleanCSS.colors[type]).join('|') + ")";
       var colorSwitcher = function(match, prefix, colorValue, suffix) {
-        return prefix + CleanCSS.colors[type][colorValue] + suffix;
+        return prefix + CleanCSS.colors[type][colorValue.toLowerCase()] + suffix;
       };
-      replace(new RegExp("([ :,\\(])" + pattern + "([;\\}!\\) ])", 'g'), colorSwitcher);
-      replace(new RegExp("(,)" + pattern + "(,)", 'g'), colorSwitcher);
+      replace(new RegExp("([ :,\\(])" + pattern + "([;\\}!\\) ])", 'ig'), colorSwitcher);
+      replace(new RegExp("(,)" + pattern + "(,)", 'ig'), colorSwitcher);
     });
 
     // replace font weight with numerical value
index 06ae154..bec7b7a 100644 (file)
@@ -455,6 +455,14 @@ vows.describe('clean-units').addBatch({
       'p{color:#f00}',
       'p{color:red}'
     ],
+    'upper case hex value to color name if shorter': [
+      'p{color:#F00}',
+      'p{color:red}'
+    ],
+    'upper case long hex value to color name if shorter': [
+      'p{color:#FF0000}',
+      'p{color:red}'
+    ],
     'hex value to color name in borders': [
       'p{border:1px solid #f00}',
       'p{border:1px solid red}'