diff --git a/jquery.color.js b/jquery.color.js index fdf459e..ef13e13 100644 --- a/jquery.color.js +++ b/jquery.color.js @@ -53,6 +53,18 @@ } }, { + // this regex ignores A-F because it's compared against an already lowercased string + re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, + parse: function( execResult ) { + return [ + parseInt( execResult[ 1 ], 16 ), + parseInt( execResult[ 2 ], 16 ), + parseInt( execResult[ 3 ], 16 ), + ( parseInt( execResult[ 4 ], 16 ) / 255.0 ).toFixed( 2 ) + ]; + } + }, { + // this regex ignores A-F because it's compared against an already lowercased string re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, parse: function( execResult ) { diff --git a/test/unit/color.js b/test/unit/color.js index 7fef488..ccad483 100644 --- a/test/unit/color.js +++ b/test/unit/color.js @@ -170,6 +170,27 @@ var sevens = { }; parseTest( "#777", sevens ); parseTest( "#777777", sevens ); +parseTest( "#77777726", { + expect: 4, + red: 119, + green: 119, + blue: 119, + alpha: 0.15 +} ); +parseTest( "#777777FF", { + expect: 4, + red: 119, + green: 119, + blue: 119, + alpha: 1 +} ); +parseTest( "#77777700", { + expect: 4, + red: 119, + green: 119, + blue: 119, + alpha: 0 +} ); var fiftypercent = { expect: 4,