From: GoalSmashers Date: Sat, 17 Nov 2012 23:54:05 +0000 (+0000) Subject: Added shortening font:(normal|bold) as font-weight is. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=bde3027d4b9b5bfec3bc4d91842aea11fa11551c;p=clean-css.git Added shortening font:(normal|bold) as font-weight is. --- diff --git a/lib/clean.js b/lib/clean.js index 3399f301..96761682 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -132,12 +132,13 @@ var CleanCSS = { replace(/([: ,\(])#f00/g, '$1red'); // replace font weight with numerical value - replace(/font\-weight:(\w+)/g, function(match, weight) { + replace(/(font|font\-weight):(normal|bold)([ ;\}!])/g, function(match, property, weight, suffix) { if (weight == 'normal') - return 'font-weight:400'; + return property + ':400' + suffix; else if (weight == 'bold') - return 'font-weight:700'; - else return match; + return property + ':700' + suffix; + else + return match; }); // IE shorter filters but only if single (IE 7 issue) diff --git a/test/unit-test.js b/test/unit-test.js index fc6dcb76..5e35774c 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -376,6 +376,14 @@ vows.describe('clean-units').addBatch({ 'font-weight:bold to 700': [ 'p{font-weight:bold}', 'p{font-weight:700}' + ], + 'font weight in font declarations': [ + 'font:normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif', + 'font:400 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif' + ], + 'multiple changes': [ + 'p{font-weight:bold;width:100%;font:normal}', + 'p{font-weight:700;width:100%;font:400}' ] }), 'urls': cssContext({