return (nonZeroPart ? '.' : '') + nonZeroPart + suffix;
});
- // restore 0% in hsl/hsla
- replace(/(hsl|hsla)\(([^\)]+)\)/g, function(match, colorFunction, colorDef) {
+ // restore % in rgb/rgba and hsl/hsla
+ replace(/(rgb|rgba|hsl|hsla)\(([^\)]+)\)/g, function(match, colorFunction, colorDef) {
var tokens = colorDef.split(',');
- if (tokens[1] == '0')
- tokens[1] = '0%';
- if (tokens[2] == '0')
- tokens[2] = '0%';
+ var applies = colorFunction == 'hsl' || colorFunction == 'hsla' || tokens[0].indexOf('%') > -1;
+ if (!applies)
+ return match;
+
+ if (tokens[1].indexOf('%') == -1)
+ tokens[1] += '%';
+ if (tokens[2].indexOf('%') == -1)
+ tokens[2] += '%';
return colorFunction + '(' + tokens.join(',') + ')';
});
'colors in ie filters': 'a{filter:chroma(color=#ffffff)}',
'colors in ie filters 2': "a{progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000')}",
'colors in ie filters 3': "a{progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#333333')}",
+ 'rgb percents': 'a{color:rgb(100%,0%,0%)}',
+ 'rgba percents': 'a{color:rgba(100%,0%,0%,.5)}',
'hsla percents': 'a{color:hsla(1,0%,0%,.5)}',
'hsla custom ': 'a{color:hsl(80,30%,50%,.5)}',
'hsl to hex #1': [