Skip to content

Commit

Permalink
add extra safety by using geoLayoutIn.visible instead of coerced visible
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jan 11, 2020
1 parent 1b905a1 commit 639913e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 40 deletions.
3 changes: 2 additions & 1 deletion src/plots/geo/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
var isClipped = geoLayoutOut._isClipped = !!constants.lonaxisSpan[projType];

var visible = coerce('visible');
if(visible === false) {
if(geoLayoutIn.visible === false) {
visible = geoLayoutOut.visible = true;
// should override template.layout.geo.show* - see issue 4482

// make a copy
Expand Down
116 changes: 77 additions & 39 deletions test/jasmine/tests/geo_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,55 +650,93 @@ describe('Test Geo layout defaults', function() {
});
}

it('- base case', function() {
layoutIn = {
template: {
layout: {
geo: {
showcoastlines: true,
showcountries: true,
showframe: true,
showland: true,
showlakes: true,
showocean: true,
showrivers: true,
showsubunits: true,
lonaxis: { showgrid: true },
lataxis: { showgrid: true }
[true, false, undefined].forEach(function(q) {
it('- base case | ' + q, function() {
layoutIn = {
template: {
layout: {
geo: {
showcoastlines: q,
showcountries: q,
showframe: q,
showland: q,
showlakes: q,
showocean: q,
showrivers: q,
showsubunits: q,
lonaxis: { showgrid: q },
lataxis: { showgrid: q }
}
}
}
},
geo: { visible: false }
};
},
geo: { visible: false }
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showsubunits: undefined
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showsubunits: undefined
});
});
});

it('- scoped case', function() {
layoutIn = {
geo: { scope: 'europe', visible: false }
};
[true, false, undefined].forEach(function(q) {
it('- scoped case', function() {
layoutIn = {
template: {
layout: {
geo: {
showcoastlines: q,
showcountries: q,
showframe: q,
showland: q,
showlakes: q,
showocean: q,
showrivers: q,
showsubunits: q,
lonaxis: { showgrid: q },
lataxis: { showgrid: q }
}
}
},
geo: { scope: 'europe', visible: false }
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showsubunits: undefined
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showsubunits: undefined
});
});
});

it('- scope:usa case', function() {
layoutIn = {
geo: { scope: 'usa', visible: false }
};
[true, false, undefined].forEach(function(q) {
it('- scope:usa case', function() {
layoutIn = {
template: {
layout: {
geo: {
showcoastlines: q,
showcountries: q,
showframe: q,
showland: q,
showlakes: q,
showocean: q,
showrivers: q,
showsubunits: q,
lonaxis: { showgrid: q },
lataxis: { showgrid: q }
}
}
},
geo: { scope: 'usa', visible: false }
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showcoastlines: undefined,
showocean: undefined
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showcoastlines: undefined,
showocean: undefined
});
});
});
});
Expand Down

0 comments on commit 639913e

Please sign in to comment.