From 5491633bf6ebf2c505ee3612f36054918e54bff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 26 Sep 2018 11:34:42 -0400 Subject: [PATCH] do not to look for 'add' and 'remove' when replacing array containers - this didn't lead to any bugs, as the correct editType was resolved, it lead to false Lib.warn message. --- src/plot_api/plot_api.js | 6 +++--- test/jasmine/tests/shapes_test.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 9bd8007dfc2..4fe0a28da59 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1979,9 +1979,10 @@ function _relayout(gd, aobj) { var obji = (componentArray || [])[i] || {}; var updateValObject = valObject || {editType: 'calc'}; - if(propStr === '') { + if(i !== '' && propStr === '') { // special handling of undoit if we're adding or removing an element - // ie 'annotations[2]' which can be {...} (add) or null (remove) + // ie 'annotations[2]' which can be {...} (add) or null, + // does not work when replacing the entire array if(manageArrays.isAddVal(vi)) { undoit[ai] = null; } else if(manageArrays.isRemoveVal(vi)) { @@ -1990,7 +1991,6 @@ function _relayout(gd, aobj) { Lib.warn('unrecognized full object value', aobj); } } - editTypes.update(flags, updateValObject); // prepare the edits object we'll send to applyContainerArrayChanges diff --git a/test/jasmine/tests/shapes_test.js b/test/jasmine/tests/shapes_test.js index bc1198445a6..b096b925570 100644 --- a/test/jasmine/tests/shapes_test.js +++ b/test/jasmine/tests/shapes_test.js @@ -367,6 +367,8 @@ describe('Test shapes:', function() { }); it('can replace the shapes array', function(done) { + spyOn(Lib, 'warn'); + Plotly.relayout(gd, { shapes: [ getRandomShape(), getRandomShape() @@ -375,6 +377,7 @@ describe('Test shapes:', function() { expect(countShapePathsInLowerLayer()).toEqual(0); expect(countShapePathsInSubplots()).toEqual(0); expect(gd.layout.shapes.length).toBe(2); + expect(Lib.warn).not.toHaveBeenCalled(); }) .catch(failTest) .then(done);