File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,25 +330,27 @@ class Color {
330330 if ( ! colorString ) {
331331 colorString = serialize ( this . _color , {
332332 format : outputFormat
333- } ) ;
333+ } ) ;
334334
335- colorString = String ( colorString ) ;
335+ if ( format === '#rrggbb' ) {
336+ colorString = String ( colorString ) ;
336337
337- if ( colorString . length <= 5 ) {
338- const match = colorString . match ( / ^ # ? ( [ 0 - 9 a - f A - F ] ) ( [ 0 - 9 a - f A - F ] ) ( [ 0 - 9 a - f A - F ] ) / ) ;
339- if ( match ) {
340- colorString = `#${ match [ 1 ] } ${ match [ 1 ] } ${ match [ 2 ] } ${ match [ 2 ] } ${ match [ 3 ] } ${ match [ 3 ] } ` ;
338+ if ( colorString . length <= 5 ) {
339+ const match = colorString . match ( / ^ # ? ( [ 0 - 9 a - f A - F ] ) ( [ 0 - 9 a - f A - F ] ) ( [ 0 - 9 a - f A - F ] ) / ) ;
340+ if ( match ) {
341+ colorString = `#${ match [ 1 ] } ${ match [ 1 ] } ${ match [ 2 ] } ${ match [ 2 ] } ${ match [ 3 ] } ${ match [ 3 ] } ` ;
342+ }
343+ }
344+ if ( colorString . length > 7 ) {
345+ colorString = colorString . substring ( 0 , 7 ) ;
346+ }
347+ colorString = colorString . toLowerCase ( ) ;
341348 }
349+
350+ serializationMap [ key ] = colorString ;
342351 }
343- if ( colorString . length > 7 ) {
344- colorString = colorString . substring ( 0 , 7 ) ;
345- }
346- colorString = colorString . toLowerCase ( ) ;
347- serializationMap [ key ] = colorString ;
348-
349352 return colorString ;
350353 }
351- }
352354
353355 /**
354356 * Checks the contrast between two colors. This method returns a boolean
You can’t perform that action at this time.
0 commit comments