* Fixed issue [#360](https://github.com/GoalSmashers/clean-css/issues/360) - adds 7 extra CSS colors.
* Fixed issue [#363](https://github.com/GoalSmashers/clean-css/issues/363) - `rem` units overriding `px`.
+[2.2.18 / 2014-11-17](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.17...v2.2.18)
+==================
+
+* Fixed issue [#383](https://github.com/GoalSmashers/clean-css/issues/383) - rounding fractions once again.
+
[2.2.17 / 2014-11-09](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.16...v2.2.17)
==================
DEFAULT_ROUNDING_PRECISION :
options.roundingPrecision;
options.precision.multiplier = Math.pow(10, options.precision.value);
- options.precision.regexp = new RegExp('\\.(\\d{' + (options.precision.value + 1) + ',})px', 'g');
+ options.precision.regexp = new RegExp('(\\d*\\.\\d{' + (options.precision.value + 1) + ',})px', 'g');
}
function removeUnsupported(token, compatibility) {
return value;
return value
- .replace(precisionOptions.regexp, function(match, decimalPlaces) {
- var newFraction = Math.round(parseFloat('.' + decimalPlaces) * precisionOptions.multiplier) / precisionOptions.multiplier;
- if (precisionOptions.value === 0 || newFraction === 0) {
- return 'px';
- } else {
- return newFraction < 1 ?
- '.' + ('' + newFraction).substring('0.'.length) + 'px' :
- newFraction + 'px';
- }
+ .replace(precisionOptions.regexp, function(match, number) {
+ return Math.round(parseFloat(number) * precisionOptions.multiplier) / precisionOptions.multiplier + 'px';
})
.replace(/(\d)\.($|\D)/g, '$1$2');
}
if (valueMinifiers[property])
value = valueMinifiers[property](value);
- value = zeroMinifier(property, value);
value = precisionMinifier(property, value, options.precision);
+ value = zeroMinifier(property, value);
value = unitMinifier(property, value, options.unitsRegexp);
value = multipleZerosMinifier(property, value);
value = colorMininifier(property, value, options.compatibility);
}),
zero: pipedContext('div{width:1.5051px}', '--rounding-precision 0', {
'should keep 0 decimal places': function(error, stdout) {
- assert.equal(stdout, 'div{width:1px}');
+ assert.equal(stdout, 'div{width:2px}');
}
}),
disabled: pipedContext('div{width:0.12345px}', '--rounding-precision \\\\-1', {
'rounds .9999 correctly': [
'a{stroke-width:.99999px}',
'a{stroke-width:1px}'
+ ],
+ 'rounds 9.995 correctly': [
+ 'a{stroke-width:9.995px}',
+ 'a{stroke-width:9.99px}'
]
}),
'floats custom rounding': cssContext({