|
54 | 54 | }, { |
55 | 55 |
|
56 | 56 | // this regex ignores A-F because it's compared against an already lowercased string |
57 | | - re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, |
| 57 | + re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/, |
58 | 58 | parse: function( execResult ) { |
59 | 59 | return [ |
60 | 60 | parseInt( execResult[ 1 ], 16 ), |
61 | 61 | parseInt( execResult[ 2 ], 16 ), |
62 | 62 | parseInt( execResult[ 3 ], 16 ), |
63 | | - ( parseInt( execResult[ 4 ], 16 ) / 255.0 ).toFixed( 2 ) |
| 63 | + execResult[ 4 ] ? |
| 64 | + ( parseInt( execResult[ 4 ], 16 ) / 255 ).toFixed( 2 ) : |
| 65 | + 1 |
64 | 66 | ]; |
65 | 67 | } |
66 | 68 | }, { |
67 | 69 |
|
68 | 70 | // this regex ignores A-F because it's compared against an already lowercased string |
69 | | - re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, |
70 | | - parse: function( execResult ) { |
71 | | - return [ |
72 | | - parseInt( execResult[ 1 ], 16 ), |
73 | | - parseInt( execResult[ 2 ], 16 ), |
74 | | - parseInt( execResult[ 3 ], 16 ) |
75 | | - ]; |
76 | | - } |
77 | | - }, { |
78 | | - |
79 | | - // this regex ignores A-F because it's compared against an already lowercased string |
80 | | - re: /#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])/, |
| 71 | + re: /#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/, |
81 | 72 | parse: function( execResult ) { |
82 | 73 | return [ |
83 | 74 | parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), |
84 | 75 | parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), |
85 | 76 | parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ), |
86 | | - ( parseInt( execResult[ 4 ] + execResult[ 4 ], 16 ) / 255 ) |
87 | | - .toFixed( 2 ) |
88 | | - ]; |
89 | | - } |
90 | | - }, { |
91 | | - |
92 | | - // this regex ignores A-F because it's compared against an already lowercased string |
93 | | - re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, |
94 | | - parse: function( execResult ) { |
95 | | - return [ |
96 | | - parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), |
97 | | - parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), |
98 | | - parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) |
| 77 | + execResult[ 4 ] ? |
| 78 | + ( parseInt( execResult[ 4 ] + execResult[ 4 ], 16 ) / 255 ) |
| 79 | + .toFixed( 2 ) : |
| 80 | + 1 |
99 | 81 | ]; |
100 | 82 | } |
101 | 83 | }, { |
|
0 commit comments