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