diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 72b40252361..eb6b85a2d25 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -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); } diff --git a/test/jasmine/tests/frame_api_test.js b/test/jasmine/tests/frame_api_test.js index fed2b0cdba5..eddcde880e5 100644 --- a/test/jasmine/tests/frame_api_test.js +++ b/test/jasmine/tests/frame_api_test.js @@ -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) { + 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']);