From 7b89338cf6901a3c7dbcb77cb8c42b279b201d67 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sat, 2 Aug 2014 10:33:47 +0100 Subject: [PATCH] Fixes #329 - font shorthands incorrectly processed. --- History.md | 1 + lib/clean.js | 2 +- test/unit-test.js | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 73d0d906..8db3e3da 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ ================== * Fixed issue with tokenizer removing first selector after an unknown @ rule. +* Fixed issue [#329](https://github.com/GoalSmashers/clean-css/issues/329) - font shorthands incorrectly processed. [2.2.11 / 2014-07-28](https://github.com/GoalSmashers/clean-css/compare/v2.2.10...v2.2.11) ================== diff --git a/lib/clean.js b/lib/clean.js index f5cbfb75..88434137 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -246,7 +246,7 @@ var minify = function(data, callback) { // replace font weight with numerical value replace(/(font\-weight|font):(normal|bold)([ ;\}!])(\w*)/g, function(match, property, weight, suffix, next) { - if (suffix == ' ' && next.length > 0 && !/[.\d]/.test(next)) + if (suffix == ' ' && (next.indexOf('/') > -1 || next == 'normal' || /[1-9]00/.test(next))) return match; if (weight == 'normal') diff --git a/test/unit-test.js b/test/unit-test.js index 9cc3f53f..e0fbd0b8 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -859,7 +859,8 @@ vows.describe('clean-units').addBatch({ 'p{font-weight:bold!important;width:100%;font:normal 12px Helvetica}', 'p{font-weight:700!important;width:100%;font:400 12px Helvetica}' ], - 'font weight in extended font declarations': 'font:normal normal normal 13px/20px Helvetica' + 'font weight in extended font declarations': 'font:normal normal normal 13px/20px Helvetica', + 'font weight where style and weight are declared': 'a{font:normal 300 100%/1.5 sans-serif}' }), 'unicode': cssContext({ 'font-names': 'body{font-family:\\5FAE\\8F6F\\96C5\\9ED1,\\5B8B\\4F53,sans-serif}' -- 2.34.1