Added shortening font:(normal|bold) as font-weight is.
authorGoalSmashers <jakub@goalsmashers.com>
Sat, 17 Nov 2012 23:54:05 +0000 (23:54 +0000)
committerGoalSmashers <jakub@goalsmashers.com>
Sat, 17 Nov 2012 23:54:05 +0000 (23:54 +0000)
lib/clean.js
test/unit-test.js

index 3399f30..9676168 100644 (file)
@@ -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)
index fc6dcb7..5e35774 100644 (file)
@@ -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({