@@ -2742,34 +2742,34 @@ const HSL_PATTERN = new SafeRegExp(
2742
2742
) ;
2743
2743
2744
2744
function parseCssColor ( colorString ) {
2745
- if ( MapPrototypeHas ( colorKeywords , colorString ) ) {
2746
- colorString = MapPrototypeGet ( colorKeywords , colorString ) ;
2745
+ if ( colorKeywords . has ( colorString ) ) {
2746
+ colorString = colorKeywords . get ( colorString ) ;
2747
2747
}
2748
2748
// deno-fmt-ignore
2749
2749
const hashMatch = StringPrototypeMatch ( colorString , HASH_PATTERN ) ;
2750
2750
if ( hashMatch != null ) {
2751
2751
return [
2752
- Number ( `0x ${ hashMatch [ 1 ] } ` ) ,
2753
- Number ( `0x ${ hashMatch [ 2 ] } ` ) ,
2754
- Number ( `0x ${ hashMatch [ 3 ] } ` ) ,
2752
+ NumberParseInt ( hashMatch [ 1 ] , 16 ) ,
2753
+ NumberParseInt ( hashMatch [ 2 ] , 16 ) ,
2754
+ NumberParseInt ( hashMatch [ 3 ] , 16 ) ,
2755
2755
] ;
2756
2756
}
2757
2757
// deno-fmt-ignore
2758
2758
const smallHashMatch = StringPrototypeMatch ( colorString , SMALL_HASH_PATTERN ) ;
2759
2759
if ( smallHashMatch != null ) {
2760
2760
return [
2761
- Number ( `0x ${ smallHashMatch [ 1 ] } ${ smallHashMatch [ 1 ] } `) ,
2762
- Number ( `0x ${ smallHashMatch [ 2 ] } ${ smallHashMatch [ 2 ] } `) ,
2763
- Number ( `0x ${ smallHashMatch [ 3 ] } ${ smallHashMatch [ 3 ] } `) ,
2761
+ NumberParseInt ( ` ${ smallHashMatch [ 1 ] } ${ smallHashMatch [ 1 ] } `, 16 ) ,
2762
+ NumberParseInt ( ` ${ smallHashMatch [ 2 ] } ${ smallHashMatch [ 2 ] } `, 16 ) ,
2763
+ NumberParseInt ( ` ${ smallHashMatch [ 3 ] } ${ smallHashMatch [ 3 ] } `, 16 ) ,
2764
2764
] ;
2765
2765
}
2766
2766
// deno-fmt-ignore
2767
2767
const rgbMatch = StringPrototypeMatch ( colorString , RGB_PATTERN ) ;
2768
2768
if ( rgbMatch != null ) {
2769
2769
return [
2770
- MathRound ( MathMax ( 0 , MathMin ( 255 , Number ( rgbMatch [ 1 ] ) ) ) ) ,
2771
- MathRound ( MathMax ( 0 , MathMin ( 255 , Number ( rgbMatch [ 2 ] ) ) ) ) ,
2772
- MathRound ( MathMax ( 0 , MathMin ( 255 , Number ( rgbMatch [ 3 ] ) ) ) ) ,
2770
+ MathRound ( MathMax ( 0 , MathMin ( 255 , rgbMatch [ 1 ] ) ) ) ,
2771
+ MathRound ( MathMax ( 0 , MathMin ( 255 , rgbMatch [ 2 ] ) ) ) ,
2772
+ MathRound ( MathMax ( 0 , MathMin ( 255 , rgbMatch [ 3 ] ) ) ) ,
2773
2773
] ;
2774
2774
}
2775
2775
// deno-fmt-ignore
@@ -2780,8 +2780,8 @@ function parseCssColor(colorString) {
2780
2780
if ( h < 0 ) {
2781
2781
h += 360 ;
2782
2782
}
2783
- const s = MathMax ( 0 , MathMin ( 100 , Number ( hslMatch [ 2 ] ) ) ) / 100 ;
2784
- const l = MathMax ( 0 , MathMin ( 100 , Number ( hslMatch [ 3 ] ) ) ) / 100 ;
2783
+ const s = MathMax ( 0 , MathMin ( 100 , hslMatch [ 2 ] ) ) / 100 ;
2784
+ const l = MathMax ( 0 , MathMin ( 100 , hslMatch [ 3 ] ) ) / 100 ;
2785
2785
const c = ( 1 - MathAbs ( 2 * l - 1 ) ) * s ;
2786
2786
const x = c * ( 1 - MathAbs ( ( h / 60 ) % 2 - 1 ) ) ;
2787
2787
const m = l - c / 2 ;
0 commit comments