Skip to content

Commit 0b48a33

Browse files
committed
robustify tickformatstops supplydefaults
1 parent 531aea8 commit 0b48a33

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/plots/cartesian/tick_label_defaults.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ function getShowAttrDflt(containerIn) {
8383
}
8484

8585
function tickformatstopsDefaults(tickformatIn, tickformatOut) {
86-
var valuesIn = tickformatIn.tickformatstops || [],
87-
valuesOut = tickformatOut.tickformatstops = [];
86+
var valuesIn = tickformatIn.tickformatstops;
87+
var valuesOut = tickformatOut.tickformatstops = [];
88+
89+
if(!Array.isArray(valuesIn)) return;
8890

8991
var valueIn, valueOut;
9092

@@ -101,6 +103,4 @@ function tickformatstopsDefaults(tickformatIn, tickformatOut) {
101103

102104
valuesOut.push(valueOut);
103105
}
104-
105-
return valuesOut;
106106
}

test/jasmine/tests/tickformatstops_test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,19 @@ describe('Test tickformatstops:', function() {
289289
.then(done);
290290
});
291291

292+
it('doesn\'t fail on bad input', function(done) {
293+
var promise = Plotly.plot(gd, mockCopy.data, mockCopy.layout);
294+
295+
[1, {a: 1, b: 2}, 'boo'].forEach(function(v) {
296+
promise = promise.then(function() {
297+
return Plotly.relayout(gd, {'xaxis.tickformatstops': v});
298+
}).then(function() {
299+
expect(gd._fullLayout.xaxis.tickformatstops).toEqual([]);
300+
});
301+
});
302+
303+
promise
304+
.catch(fail)
305+
.then(done);
306+
});
292307
});

0 commit comments

Comments
 (0)