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 {
1313 availableImages : Array < string > ;
1414 canonical : ICanonicalTileID ;
1515
16- _parseColorCache : { [ _ : string ] : Color } ;
16+ _parseColorCache : Map < string , Color > ;
1717
1818 constructor ( ) {
1919 this . globals = null ;
2020 this . feature = null ;
2121 this . featureState = null ;
2222 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 > ( ) ;
2624 this . availableImages = null ;
2725 this . canonical = null ;
2826 }
@@ -48,9 +46,10 @@ export class EvaluationContext {
4846 }
4947
5048 parseColor ( input : string ) : Color {
51- let cached = this . _parseColorCache [ input ] ;
49+ let cached = this . _parseColorCache . get ( input ) ;
5250 if ( ! cached ) {
53- cached = this . _parseColorCache [ input ] = Color . parse ( input ) ;
51+ cached = Color . parse ( input ) ;
52+ this . _parseColorCache . set ( input , cached ) ;
5453 }
5554 return cached ;
5655 }
You can’t perform that action at this time.
0 commit comments