File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -384,15 +384,14 @@ class Color {
384384
385385 if ( format === '#rrggbb' ) {
386386 colorString = String ( colorString ) ;
387-
388- if ( colorString . length <= 5 ) {
389- const match = colorString . match ( / ^ # ? ( [ 0 - 9 a - f A - F ] ) ( [ 0 - 9 a - f A - F ] ) ( [ 0 - 9 a - f A - F ] ) / ) ;
390- if ( match ) {
391- colorString = `#${ match [ 1 ] } ${ match [ 1 ] } ${ match [ 2 ] } ${ match [ 2 ] } ${ match [ 3 ] } ${ match [ 3 ] } ` ;
392- }
387+ if ( colorString . length === 4 ) {
388+ const r = colorString [ 1 ] ;
389+ const g = colorString [ 2 ] ;
390+ const b = colorString [ 3 ] ;
391+ colorString = `#${ r } ${ r } ${ g } ${ g } ${ b } ${ b } ` ;
393392 }
394393 if ( colorString . length > 7 ) {
395- colorString = colorString . substring ( 0 , 7 ) ;
394+ colorString = colorString . slice ( 0 , 7 ) ;
396395 }
397396 colorString = colorString . toLowerCase ( ) ;
398397 }
@@ -404,7 +403,6 @@ class Color {
404403 }
405404 return colorString ;
406405 }
407-
408406 /**
409407 * Checks the contrast between two colors. This method returns a boolean
410408 * value to indicate if the two color has enough contrast. `true` means that
You can’t perform that action at this time.
0 commit comments