Fixed problem with space before color in 'border' property.
authorJakub Pawlowicz <jakub@goalsmashers.com>
Sun, 17 Apr 2011 14:52:09 +0000 (16:52 +0200)
committerJakub Pawlowicz <jakub@goalsmashers.com>
Sun, 17 Apr 2011 14:52:09 +0000 (16:52 +0200)
lib/clean.js
test/unit-test.js

index 2ead47d..818cf96 100644 (file)
@@ -85,9 +85,9 @@ var CleanCSS = {
     })
     replace(/([^"'=\s])\s*#([0-9a-f]{6})/gi, function(match, prefix, color) { // long hex to short hex
       if (color[0] == color[1] && color[2] == color[3] && color[4] == color[5])
-        return prefix + '#' + color[0] + color[2] + color[4];
+        return (prefix + (/:$/.test(prefix) ? '' : ' ')) + '#' + color[0] + color[2] + color[4];
       else
-        return prefix + '#' + color;
+        return (prefix + (/:$/.test(prefix) ? '' : ' ')) + '#' + color;
     })
     replace(/(color|background):(\w+)/g, function(match, property, colorName) { // replace standard colors with hex values (only if color name is longer then hex value)
       if (CleanCSS.colors[colorName]) return property + ':' + CleanCSS.colors[colorName];
index 965a04e..fc28d8f 100644 (file)
@@ -213,6 +213,10 @@ vows.describe('clean-units').addBatch({
     'hex value to color name': [
       'p{color:#f00}',
       'p{color:red}'
+    ],
+    'border color': [
+      'p{border:1px solid #f94311}',
+      'p{border:1px solid #f94311}'
     ]
   }),
   'font weights': cssContext({