From: Jakub Pawlowicz Date: Sun, 17 Apr 2011 14:52:09 +0000 (+0200) Subject: Fixed problem with space before color in 'border' property. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=cb0140ab1f15f916a822e9c81ed5c5ea41b08357;p=clean-css.git Fixed problem with space before color in 'border' property. --- 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({