Skip to content

Commit 5491633

Browse files
committed
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.
1 parent a070a8d commit 5491633

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/plot_api/plot_api.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1979,9 +1979,10 @@ function _relayout(gd, aobj) {
19791979
var obji = (componentArray || [])[i] || {};
19801980
var updateValObject = valObject || {editType: 'calc'};
19811981

1982-
if(propStr === '') {
1982+
if(i !== '' && propStr === '') {
19831983
// special handling of undoit if we're adding or removing an element
1984-
// ie 'annotations[2]' which can be {...} (add) or null (remove)
1984+
// ie 'annotations[2]' which can be {...} (add) or null,
1985+
// does not work when replacing the entire array
19851986
if(manageArrays.isAddVal(vi)) {
19861987
undoit[ai] = null;
19871988
} else if(manageArrays.isRemoveVal(vi)) {
@@ -1990,7 +1991,6 @@ function _relayout(gd, aobj) {
19901991
Lib.warn('unrecognized full object value', aobj);
19911992
}
19921993
}
1993-
19941994
editTypes.update(flags, updateValObject);
19951995

19961996
// prepare the edits object we'll send to applyContainerArrayChanges

test/jasmine/tests/shapes_test.js

+3
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ describe('Test shapes:', function() {
367367
});
368368

369369
it('can replace the shapes array', function(done) {
370+
spyOn(Lib, 'warn');
371+
370372
Plotly.relayout(gd, { shapes: [
371373
getRandomShape(),
372374
getRandomShape()
@@ -375,6 +377,7 @@ describe('Test shapes:', function() {
375377
expect(countShapePathsInLowerLayer()).toEqual(0);
376378
expect(countShapePathsInSubplots()).toEqual(0);
377379
expect(gd.layout.shapes.length).toBe(2);
380+
expect(Lib.warn).not.toHaveBeenCalled();
378381
})
379382
.catch(failTest)
380383
.then(done);

0 commit comments

Comments
 (0)