Skip to content

Commit

Permalink
Review nits: set an interim paint in style_layer (#9688)
Browse files Browse the repository at this point in the history
* set an interim paint in style_layer

* add a simple test for undefined paint

* Address review nits

* Silence inconsistent flow error

Co-authored-by: Nick Mann <nick_j_mann@uk.ibm.com>
  • Loading branch information
karimnaaji and mannnick24 committed May 14, 2020
1 parent c8c4f87 commit ef0884e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class Tile {

bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas && this.imageAtlas.patternPositions || {});
const layer = painter && painter.style && painter.style.getLayer(id);
if (layer && layer.paint) {
if (layer) {
this.queryPadding = Math.max(this.queryPadding, layer.queryRadius(bucket));
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/style/style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
emitValidationErrors
} from './validate_style';
import {Evented} from '../util/evented';
import {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluatedPropertyValue} from './properties';
import {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluated, PossiblyEvaluatedPropertyValue} from './properties';
import {supportsPropertyExpression} from '../style-spec/util/properties';

import type {FeatureState} from '../style-spec/expression';
Expand Down Expand Up @@ -100,6 +100,8 @@ class StyleLayer extends Evented {
}

this._transitioningPaint = this._transitionablePaint.untransitioned();
//$FlowFixMe
this.paint = new PossiblyEvaluated(properties.paint);
}
}

Expand Down
7 changes: 7 additions & 0 deletions test/unit/style/style_layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,12 @@ test('StyleLayer#serialize', (t) => {
t.end();
});

t.test('layer.paint is never undefined', (t) => {
const layer = createStyleLayer({type: 'fill'});
// paint is never undefined
t.ok(layer.paint);
t.end();
});

t.end();
});

0 comments on commit ef0884e

Please sign in to comment.