Fixes #329 - font shorthands incorrectly processed.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 2 Aug 2014 09:33:47 +0000 (10:33 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 2 Aug 2014 10:40:22 +0000 (11:40 +0100)
History.md
lib/clean.js
test/unit-test.js

index 73d0d90..8db3e3d 100644 (file)
@@ -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)
 ==================
index f5cbfb7..8843413 100644 (file)
@@ -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')
index 9cc3f53..e0fbd0b 100644 (file)
@@ -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}'