From cb0140ab1f15f916a822e9c81ed5c5ea41b08357 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sun, 17 Apr 2011 16:52:09 +0200 Subject: [PATCH] Fixed problem with space before color in 'border' property. --- lib/clean.js | 4 ++-- test/unit-test.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/clean.js b/lib/clean.js index 2ead47d7..818cf960 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -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]; diff --git a/test/unit-test.js b/test/unit-test.js index 965a04e6..fc28d8fb 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -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({ -- 2.34.1