Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,10 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
Plotly.addFrames = function(gd, frameList, indices) {
gd = helpers.getGraphDiv(gd);

if(frameList === null || frameList === undefined) {
return Promise.resolve();
}

if(!Lib.isPlotDiv(gd)) {
throw new Error('This element is not a Plotly plot: ' + gd);
}
Expand Down
18 changes: 18 additions & 0 deletions test/jasmine/tests/frame_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ describe('Test frame api', function() {
});

describe('#addFrames', function() {
it('treats an undefined list as a noop', function(done) {
Plotly.addFrames(gd, undefined).then(function() {
expect(Object.keys(h)).toEqual([]);
}).catch(fail).then(done);
});

it('treats a null list as a noop', function(done) {
Plotly.addFrames(gd, null).then(function() {
expect(Object.keys(h)).toEqual([]);
}).catch(fail).then(done);
});

it('treats an empty list as a noop', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good 💃

Plotly.addFrames(gd, []).then(function() {
expect(Object.keys(h)).toEqual([]);
}).catch(fail).then(done);
});

it('names an unnamed frame', function(done) {
Plotly.addFrames(gd, [{}]).then(function() {
expect(Object.keys(h)).toEqual(['frame 0']);
Expand Down