Skip to content

Commit 639913e

Browse files
committed
add extra safety by using geoLayoutIn.visible instead of coerced visible
1 parent 1b905a1 commit 639913e

File tree

2 files changed

+79
-40
lines changed

2 files changed

+79
-40
lines changed

src/plots/geo/layout_defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
4646
var isClipped = geoLayoutOut._isClipped = !!constants.lonaxisSpan[projType];
4747

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

5253
// make a copy

test/jasmine/tests/geo_test.js

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -650,55 +650,93 @@ describe('Test Geo layout defaults', function() {
650650
});
651651
}
652652

653-
it('- base case', function() {
654-
layoutIn = {
655-
template: {
656-
layout: {
657-
geo: {
658-
showcoastlines: true,
659-
showcountries: true,
660-
showframe: true,
661-
showland: true,
662-
showlakes: true,
663-
showocean: true,
664-
showrivers: true,
665-
showsubunits: true,
666-
lonaxis: { showgrid: true },
667-
lataxis: { showgrid: true }
653+
[true, false, undefined].forEach(function(q) {
654+
it('- base case | ' + q, function() {
655+
layoutIn = {
656+
template: {
657+
layout: {
658+
geo: {
659+
showcoastlines: q,
660+
showcountries: q,
661+
showframe: q,
662+
showland: q,
663+
showlakes: q,
664+
showocean: q,
665+
showrivers: q,
666+
showsubunits: q,
667+
lonaxis: { showgrid: q },
668+
lataxis: { showgrid: q }
669+
}
668670
}
669-
}
670-
},
671-
geo: { visible: false }
672-
};
671+
},
672+
geo: { visible: false }
673+
};
673674

674-
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
675-
_assert({
676-
showsubunits: undefined
675+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
676+
_assert({
677+
showsubunits: undefined
678+
});
677679
});
678680
});
679681

680-
it('- scoped case', function() {
681-
layoutIn = {
682-
geo: { scope: 'europe', visible: false }
683-
};
682+
[true, false, undefined].forEach(function(q) {
683+
it('- scoped case', function() {
684+
layoutIn = {
685+
template: {
686+
layout: {
687+
geo: {
688+
showcoastlines: q,
689+
showcountries: q,
690+
showframe: q,
691+
showland: q,
692+
showlakes: q,
693+
showocean: q,
694+
showrivers: q,
695+
showsubunits: q,
696+
lonaxis: { showgrid: q },
697+
lataxis: { showgrid: q }
698+
}
699+
}
700+
},
701+
geo: { scope: 'europe', visible: false }
702+
};
684703

685-
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
686-
_assert({
687-
showframe: undefined,
688-
showsubunits: undefined
704+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
705+
_assert({
706+
showframe: undefined,
707+
showsubunits: undefined
708+
});
689709
});
690710
});
691711

692-
it('- scope:usa case', function() {
693-
layoutIn = {
694-
geo: { scope: 'usa', visible: false }
695-
};
712+
[true, false, undefined].forEach(function(q) {
713+
it('- scope:usa case', function() {
714+
layoutIn = {
715+
template: {
716+
layout: {
717+
geo: {
718+
showcoastlines: q,
719+
showcountries: q,
720+
showframe: q,
721+
showland: q,
722+
showlakes: q,
723+
showocean: q,
724+
showrivers: q,
725+
showsubunits: q,
726+
lonaxis: { showgrid: q },
727+
lataxis: { showgrid: q }
728+
}
729+
}
730+
},
731+
geo: { scope: 'usa', visible: false }
732+
};
696733

697-
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
698-
_assert({
699-
showframe: undefined,
700-
showcoastlines: undefined,
701-
showocean: undefined
734+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
735+
_assert({
736+
showframe: undefined,
737+
showcoastlines: undefined,
738+
showocean: undefined
739+
});
702740
});
703741
});
704742
});

0 commit comments

Comments
 (0)