Skip to content

Commit

Permalink
Fixes incorrectly appending '%'s to rgba of numbers (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
louietan authored and jakubpawlowicz committed Jan 19, 2023
1 parent f1047cd commit d9b4c63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/optimizer/level-1/value-optimizers/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var plugin = {
var applies = (colorFnLowercase == 'hsl' && tokens.length == 3)
|| (colorFnLowercase == 'hsla' && tokens.length == 4)
|| (colorFnLowercase == 'rgb' && tokens.length === 3 && colorDef.indexOf('%') > 0)
|| (colorFnLowercase == 'rgba' && tokens.length == 4 && colorDef.indexOf('%') > 0);
|| (colorFnLowercase == 'rgba' && tokens.length == 4 && tokens[0].indexOf('%') > 0);

if (!applies) {
return match;
Expand Down
8 changes: 8 additions & 0 deletions test/optimizer/level-1/optimize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ vows.describe('level 1 optimizations')
'a{color:rgba(255,254,253,.5)}',
'a{color:rgba(255,254,253,.5)}'
],
'rgba of numbers': [
'a{color:rgba(255,255,255,50%)}',
'a{color:rgba(255,255,255,50%)}'
],
'rgba of percentages': [
'a{color:rgba(100%,100%,100%,50%)}',
'a{color:rgba(100%,100%,100%,50%)}'
],
'hsl to hex': [
'a{color:hsl(240,100%,50%)}',
'a{color:#00f}'
Expand Down

0 comments on commit d9b4c63

Please sign in to comment.