@@ -93,7 +93,7 @@ export class StyleExpression {
9393 formattedSection ?: FormattedSection
9494 ) : any {
9595 if ( this . _globalState ) {
96- globals = { ... globals , globalState : this . _globalState } ;
96+ globals = addGlobalState ( globals , this . _globalState ) ;
9797 }
9898 this . _evaluator . globals = globals ;
9999 this . _evaluator . feature = feature ;
@@ -114,7 +114,7 @@ export class StyleExpression {
114114 formattedSection ?: FormattedSection
115115 ) : any {
116116 if ( this . _globalState ) {
117- globals = { ... globals , globalState : this . _globalState } ;
117+ globals = addGlobalState ( globals , this . _globalState ) ;
118118 }
119119 this . _evaluator . globals = globals ;
120120 this . _evaluator . feature = feature || null ;
@@ -196,7 +196,7 @@ export class ZoomConstantExpression<Kind extends EvaluationKind> {
196196 formattedSection ?: FormattedSection
197197 ) : any {
198198 if ( this . _globalState ) {
199- globals = { ... globals , globalState : this . _globalState } ;
199+ globals = addGlobalState ( globals , this . _globalState ) ;
200200 }
201201 return this . _styleExpression . evaluateWithoutErrorHandling ( globals , feature , featureState , canonical , availableImages , formattedSection ) ;
202202 }
@@ -210,7 +210,7 @@ export class ZoomConstantExpression<Kind extends EvaluationKind> {
210210 formattedSection ?: FormattedSection
211211 ) : any {
212212 if ( this . _globalState ) {
213- globals = { ... globals , globalState : this . _globalState } ;
213+ globals = addGlobalState ( globals , this . _globalState ) ;
214214 }
215215 return this . _styleExpression . evaluate ( globals , feature , featureState , canonical , availableImages , formattedSection ) ;
216216 }
@@ -244,7 +244,7 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
244244 formattedSection ?: FormattedSection
245245 ) : any {
246246 if ( this . _globalState ) {
247- globals = { ... globals , globalState : this . _globalState } ;
247+ globals = addGlobalState ( globals , this . _globalState ) ;
248248 }
249249 return this . _styleExpression . evaluateWithoutErrorHandling ( globals , feature , featureState , canonical , availableImages , formattedSection ) ;
250250 }
@@ -258,7 +258,7 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
258258 formattedSection ?: FormattedSection
259259 ) : any {
260260 if ( this . _globalState ) {
261- globals = { ... globals , globalState : this . _globalState } ;
261+ globals = addGlobalState ( globals , this . _globalState ) ;
262262 }
263263 return this . _styleExpression . evaluate ( globals , feature , featureState , canonical , availableImages , formattedSection ) ;
264264 }
@@ -551,3 +551,23 @@ function getDefaultValue(spec: StylePropertySpecification): Value {
551551 return ( spec . default === undefined ? null : spec . default ) ;
552552 }
553553}
554+
555+ function addGlobalState ( globals : GlobalProperties , globalState : Record < string , any > ) : GlobalProperties {
556+ const {
557+ zoom,
558+ heatmapDensity,
559+ elevation,
560+ lineProgress,
561+ isSupportedScript,
562+ accumulated
563+ } = globals ?? { } ;
564+ return {
565+ zoom,
566+ heatmapDensity,
567+ elevation,
568+ lineProgress,
569+ isSupportedScript,
570+ accumulated,
571+ globalState
572+ } ;
573+ }
0 commit comments