From 639913e2f7e77e93a4cd0db40a1a19f67d2b82e4 Mon Sep 17 00:00:00 2001 From: archmoj Date: Fri, 10 Jan 2020 20:46:58 -0500 Subject: [PATCH] add extra safety by using geoLayoutIn.visible instead of coerced visible --- src/plots/geo/layout_defaults.js | 3 +- test/jasmine/tests/geo_test.js | 116 ++++++++++++++++++++----------- 2 files changed, 79 insertions(+), 40 deletions(-) diff --git a/src/plots/geo/layout_defaults.js b/src/plots/geo/layout_defaults.js index aebb89a94ac..ccbb90a2173 100644 --- a/src/plots/geo/layout_defaults.js +++ b/src/plots/geo/layout_defaults.js @@ -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 diff --git a/test/jasmine/tests/geo_test.js b/test/jasmine/tests/geo_test.js index 10516e87aa0..d95642dde99 100644 --- a/test/jasmine/tests/geo_test.js +++ b/test/jasmine/tests/geo_test.js @@ -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 + }); }); }); });