* Fixed issue [#521](https://github.com/jakubpawlowicz/clean-css/issues/521) - unit optimizations inside `calc()`.
* Fixed issue [#526](https://github.com/jakubpawlowicz/clean-css/issues/526) - shorthand overriding into a function.
* Fixed issue [#528](https://github.com/jakubpawlowicz/clean-css/issues/528) - better support for IE<9 hacks.
+* Fixed issue [#529](https://github.com/jakubpawlowicz/clean-css/issues/529) - wrong font weight minification.
[3.1.9 / 2015-04-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.8...v3.1.9)
==================
var CHARSET_TOKEN = '@charset';
var CHARSET_REGEXP = new RegExp('^' + CHARSET_TOKEN, 'i');
+var FONT_NUMERAL_WEIGHTS = ['100', '200', '300', '400', '500', '600', '700', '800', '900'];
+var FONT_NAME_WEIGHTS = ['normal', 'bold', 'bolder', 'lighter'];
+
function SimpleOptimizer(options) {
this.options = options;
}
function minifyFont(property) {
- if (property[2] && property[2][0] != 'normal' && property[2][0] != 'bold' && !/^[1-9]00/.test(property[2][0]))
- property[1][0] = valueMinifiers['font-weight'](property[1][0]);
+ var hasNumeral = FONT_NUMERAL_WEIGHTS.indexOf(property[1][0]) > -1 ||
+ property[2] && FONT_NUMERAL_WEIGHTS.indexOf(property[2][0]) > -1 ||
+ property[3] && FONT_NUMERAL_WEIGHTS.indexOf(property[3][0]) > -1;
+
+ if (hasNumeral)
+ return;
+
+ var normalCount = 0;
+ if (property[1][0] == 'normal')
+ normalCount++;
+ if (property[2] && property[2][0] == 'normal')
+ normalCount++;
+ if (property[3] && property[3][0] == 'normal')
+ normalCount++;
+
+ if (normalCount > 1)
+ return;
+
+ var toOptimize;
+ if (FONT_NAME_WEIGHTS.indexOf(property[1][0]) > -1)
+ toOptimize = 1;
+ else if (property[2] && FONT_NAME_WEIGHTS.indexOf(property[2][0]) > -1)
+ toOptimize = 2;
+ else if (property[3] && FONT_NAME_WEIGHTS.indexOf(property[3][0]) > -1)
+ toOptimize = 3;
+
+ if (toOptimize)
+ property[toOptimize][0] = valueMinifiers['font-weight'](property[toOptimize][0]);
}
function optimizeBody(properties, options) {
'with mixed order of variant and style': [
'a{font:normal 300 normal 13px/20px sans-serif}',
[['font', 'normal', '300', 'normal', '13px', '/', '20px', 'sans-serif']]
+ ],
+ 'with mixed normal and weight': [
+ 'a{font: normal small-caps 400 medium Georgia, sans-serif;}',
+ [['font', 'normal', 'small-caps', '400', 'medium', 'Georgia', ',', 'sans-serif']]
]
})
)