File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -13,16 +13,14 @@ export class EvaluationContext {
13
13
availableImages : Array < string > ;
14
14
canonical : ICanonicalTileID ;
15
15
16
- _parseColorCache : { [ _ : string ] : Color } ;
16
+ _parseColorCache : Map < string , Color > ;
17
17
18
18
constructor ( ) {
19
19
this . globals = null ;
20
20
this . feature = null ;
21
21
this . featureState = null ;
22
22
this . formattedSection = null ;
23
- // the cache keys are user controlled (from the source JSON), so
24
- // avoid prototype pollution by creating a record with a null prototype
25
- this . _parseColorCache = Object . create ( null ) as { [ _ : string ] : Color } ;
23
+ this . _parseColorCache = new Map < string , Color > ( ) ;
26
24
this . availableImages = null ;
27
25
this . canonical = null ;
28
26
}
@@ -48,9 +46,10 @@ export class EvaluationContext {
48
46
}
49
47
50
48
parseColor ( input : string ) : Color {
51
- let cached = this . _parseColorCache [ input ] ;
49
+ let cached = this . _parseColorCache . get ( input ) ;
52
50
if ( ! cached ) {
53
- cached = this . _parseColorCache [ input ] = Color . parse ( input ) ;
51
+ cached = Color . parse ( input ) ;
52
+ this . _parseColorCache . set ( input , cached )
54
53
}
55
54
return cached ;
56
55
}
You can’t perform that action at this time.
0 commit comments