* Fixed issue [#442](https://github.com/GoalSmashers/clean-css/issues/442) - space before adjacent `nav`.
* Fixed issue [#445](https://github.com/GoalSmashers/clean-css/issues/445) - regression issue in url processor.
+[3.0.8 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.7...v3.0.8)
+==================
+
+* Fixed issue [#450](https://github.com/GoalSmashers/clean-css/issues/450) - name to hex color converting.
+
[3.0.7 / 2015-01-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.6...v3.0.7)
==================
toHex[name] = hex;
}
-var toHexPattern = new RegExp('(' + Object.keys(toHex).join('|') + ')( |,|\\)|$)', 'ig');
+var toHexPattern = new RegExp('(^| |,|\\))(' + Object.keys(toHex).join('|') + ')( |,|\\)|$)', 'ig');
var toNamePattern = new RegExp('(' + Object.keys(toName).join('|') + ')([^a-f0-9]|$)', 'ig');
+function hexConverter(match, prefix, colorValue, suffix) {
+ return prefix + toHex[colorValue.toLowerCase()] + suffix;
+}
+
+function nameConverter(match, colorValue, suffix) {
+ return toName[colorValue.toLowerCase()] + suffix;
+}
+
HexNameShortener.shorten = function (value) {
var hasHex = value.indexOf('#') > -1;
- var shortened = value.replace(toHexPattern, function(match, colorValue, suffix) {
- return toHex[colorValue.toLowerCase()] + suffix;
- });
+ var shortened = value.replace(toHexPattern, hexConverter);
- if (hasHex) {
- shortened = shortened.replace(toNamePattern, function(match, colorValue, suffix) {
- return toName[colorValue.toLowerCase()] + suffix;
- });
- }
+ if (shortened != value)
+ shortened = shortened.replace(toHexPattern, hexConverter);
- return shortened;
+ return hasHex ? shortened.replace(toNamePattern, nameConverter) : shortened;
};
module.exports = HexNameShortener;
'partial name further down to hex': [
'a{background:url(test.png) blueish}',
['background:url(test.png) blueish']
+ ],
+ 'partial name as a suffix': [
+ 'a{font-family:alrightsanslp-black}',
+ ['font-family:alrightsanslp-black']
]
})
)