Skip to content

Commit dd94b9f

Browse files
authored
Merge pull request #1013 from plotly/add-frames-noop
Make null/undefined a noop for addFrames
2 parents 85dacd7 + 93d33dc commit dd94b9f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/plot_api/plot_api.js

+4
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,10 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
24472447
Plotly.addFrames = function(gd, frameList, indices) {
24482448
gd = helpers.getGraphDiv(gd);
24492449

2450+
if(frameList === null || frameList === undefined) {
2451+
return Promise.resolve();
2452+
}
2453+
24502454
if(!Lib.isPlotDiv(gd)) {
24512455
throw new Error('This element is not a Plotly plot: ' + gd);
24522456
}

test/jasmine/tests/frame_api_test.js

+18
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ describe('Test frame api', function() {
3636
});
3737

3838
describe('#addFrames', function() {
39+
it('treats an undefined list as a noop', function(done) {
40+
Plotly.addFrames(gd, undefined).then(function() {
41+
expect(Object.keys(h)).toEqual([]);
42+
}).catch(fail).then(done);
43+
});
44+
45+
it('treats a null list as a noop', function(done) {
46+
Plotly.addFrames(gd, null).then(function() {
47+
expect(Object.keys(h)).toEqual([]);
48+
}).catch(fail).then(done);
49+
});
50+
51+
it('treats an empty list as a noop', function(done) {
52+
Plotly.addFrames(gd, []).then(function() {
53+
expect(Object.keys(h)).toEqual([]);
54+
}).catch(fail).then(done);
55+
});
56+
3957
it('names an unnamed frame', function(done) {
4058
Plotly.addFrames(gd, [{}]).then(function() {
4159
expect(Object.keys(h)).toEqual(['frame 0']);

0 commit comments

Comments
 (0)