Fix layer zIndex test with falsy values
This commit is contained in:
@@ -108,11 +108,12 @@ class BaseLayer extends BaseObject {
|
||||
managed: opt_managed === undefined ? true : opt_managed,
|
||||
hasOverlay: false
|
||||
});
|
||||
const zIndex = this.getZIndex();
|
||||
state.opacity = clamp(Math.round(this.getOpacity() * 100) / 100, 0, 1);
|
||||
state.sourceState = this.getSourceState();
|
||||
state.visible = this.getVisible();
|
||||
state.extent = this.getExtent();
|
||||
state.zIndex = this.getZIndex() || (state.managed === false ? Infinity : 0);
|
||||
state.zIndex = zIndex !== undefined ? zIndex : (state.managed === false ? Infinity : 0);
|
||||
state.maxResolution = this.getMaxResolution();
|
||||
state.minResolution = Math.max(this.getMinResolution(), 0);
|
||||
state.minZoom = this.getMinZoom();
|
||||
|
||||
@@ -650,10 +650,12 @@ describe('ol.layer.Layer', function() {
|
||||
});
|
||||
|
||||
it('respects the configured zIndex', function() {
|
||||
layer.setZIndex(42);
|
||||
map.dispatchEvent(new RenderEvent('precompose', null, frameState, null));
|
||||
const layerState = frameState.layerStatesArray[0];
|
||||
expect(layerState.zIndex).to.be(42);
|
||||
[-5, 0, 42].forEach(index => {
|
||||
layer.setZIndex(index);
|
||||
map.dispatchEvent(new RenderEvent('precompose', null, frameState, null));
|
||||
const layerState = frameState.layerStatesArray[0];
|
||||
expect(layerState.zIndex).to.be(index);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user