Skip to content

Skip over non-object mapbox layer containers #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/plots/mapbox/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ function handleLayerDefaults(containerIn, containerOut) {
}

for(var i = 0; i < layersIn.length; i++) {
layerIn = layersIn[i] || {};
layerIn = layersIn[i];
layerOut = {};

if(!Lib.isPlainObject(layerIn)) continue;

var sourceType = coerce('sourcetype');
coerce('source');

Expand Down Expand Up @@ -86,6 +88,7 @@ function handleLayerDefaults(containerIn, containerOut) {
coerce('symbol.textposition');
}

layerOut._index = i;
layersOut.push(layerOut);
}
}
14 changes: 14 additions & 0 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ describe('mapbox defaults', function() {
expect(layoutOut.mapbox.layers[1].sourcetype).toEqual('geojson');
});

it('should skip over non-object layer containers', function() {
layoutIn = {
mapbox: {
layers: [{}, null, 'remove', {}]
}
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
expect(layoutOut.mapbox.layers[0].sourcetype).toEqual('geojson');
expect(layoutOut.mapbox.layers[0]._index).toEqual(0);
expect(layoutOut.mapbox.layers[1].sourcetype).toEqual('geojson');
expect(layoutOut.mapbox.layers[1]._index).toEqual(3);
});

it('should coerce \'sourcelayer\' only for *vector* \'sourcetype\'', function() {
layoutIn = {
mapbox: {
Expand Down