Skip to content

Commit 2d84a8f

Browse files
committed
fix #2633 - make sure we have a grid before attaching it to layoutOut
1 parent 171ea31 commit 2d84a8f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/components/grid/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function sizeDefaults(layoutIn, layoutOut) {
201201
if(hasXaxes) dfltColumns = xAxes.length;
202202
}
203203

204-
var gridOut = layoutOut.grid = {};
204+
var gridOut = {};
205205

206206
function coerce(attr, dflt) {
207207
return Lib.coerce(gridIn, gridOut, gridAttrs, attr, dflt);
@@ -234,6 +234,8 @@ function sizeDefaults(layoutIn, layoutOut) {
234234
x: fillGridPositions('x', coerce, dfltGapX, dfltSideX, columns),
235235
y: fillGridPositions('y', coerce, dfltGapY, dfltSideY, rows, reversed)
236236
};
237+
238+
layoutOut.grid = gridOut;
237239
}
238240

239241
// coerce x or y sizing attributes and return an array of domains for this direction

test/jasmine/tests/plots_test.js

+19
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,25 @@ describe('grids', function() {
908908
});
909909
}
910910

911+
it('does not barf on invalid grid objects', function(done) {
912+
Plotly.newPlot(gd, makeData(['xy']), {grid: true})
913+
.then(function() {
914+
expect(gd._fullLayout.grid).toBeUndefined();
915+
916+
return Plotly.newPlot(gd, makeData(['xy']), {grid: {}});
917+
})
918+
.then(function() {
919+
expect(gd._fullLayout.grid).toBeUndefined();
920+
921+
return Plotly.newPlot(gd, makeData(['xy']), {grid: {rows: 1, columns: 1}});
922+
})
923+
.then(function() {
924+
expect(gd._fullLayout.grid).toBeUndefined();
925+
})
926+
.catch(failTest)
927+
.then(done);
928+
});
929+
911930
it('defaults to a coupled layout', function(done) {
912931
Plotly.newPlot(gd,
913932
// leave some empty rows/columns

0 commit comments

Comments
 (0)