diff --git a/jquery.color.js b/jquery.color.js index ef13e13..8750e01 100644 --- a/jquery.color.js +++ b/jquery.color.js @@ -76,6 +76,19 @@ } }, { + // this regex ignores A-F because it's compared against an already lowercased string + re: /#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])/, + parse: function( execResult ) { + return [ + parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), + parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), + parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ), + ( parseInt( execResult[ 4 ] + execResult[ 4 ], 16 ) / 255 ) + .toFixed( 2 ) + ]; + } + }, { + // this regex ignores A-F because it's compared against an already lowercased string re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, parse: function( execResult ) { diff --git a/test/unit/color.js b/test/unit/color.js index ccad483..aff20c6 100644 --- a/test/unit/color.js +++ b/test/unit/color.js @@ -192,6 +192,28 @@ parseTest( "#77777700", { alpha: 0 } ); +parseTest( "#7776", { + expect: 4, + red: 119, + green: 119, + blue: 119, + alpha: 0.4 +} ); +parseTest( "#777F", { + expect: 4, + red: 119, + green: 119, + blue: 119, + alpha: 1 +} ); +parseTest( "#7770", { + expect: 4, + red: 119, + green: 119, + blue: 119, + alpha: 0 +} ); + var fiftypercent = { expect: 4, red: 127,