Skip to content

Commit d3d54be

Browse files
authored
incorrect use of mergeWith causing mutation to _fullLayout (#1204)
* Fix bug causing `_fullData` property to be modified in mergeWith operation * Don't include function values in delta object creation
1 parent f9b17fe commit d3d54be

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Diff for: js/src/Figure.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ var FigureView = widgets.DOMWidgetView.extend({
870870
*
871871
*/
872872
getFullData: function () {
873-
return _.mergeWith(this.el._fullData, this.el.data,
873+
return _.mergeWith({}, this.el._fullData, this.el.data,
874874
fullMergeCustomizer)
875875
},
876876

@@ -881,7 +881,7 @@ var FigureView = widgets.DOMWidgetView.extend({
881881
* necessary
882882
*/
883883
getFullLayout: function () {
884-
return _.mergeWith(this.el._fullLayout, this.el.layout,
884+
return _.mergeWith({}, this.el._fullLayout, this.el.layout,
885885
fullMergeCustomizer);
886886
},
887887

@@ -1836,8 +1836,10 @@ function createDeltaObject(fullObj, removeObj) {
18361836
// the special case handling of this method
18371837
res[p] = createDeltaObject(fullVal, {});
18381838

1839-
} else if (fullVal !== undefined) {
1840-
// No recursion necessary, Just keep value from fullObj
1839+
} else if (fullVal !== undefined &&
1840+
typeof fullVal !== 'function') {
1841+
// No recursion necessary, Just keep value from fullObj.
1842+
// But skip values with function type
18411843
res[p] = fullVal;
18421844
}
18431845
}

Diff for: plotlywidget/static/index.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -13371,7 +13371,7 @@ var FigureView = widgets.DOMWidgetView.extend({
1337113371
*
1337213372
*/
1337313373
getFullData: function () {
13374-
return _.mergeWith(this.el._fullData, this.el.data,
13374+
return _.mergeWith({}, this.el._fullData, this.el.data,
1337513375
fullMergeCustomizer)
1337613376
},
1337713377

@@ -13382,7 +13382,7 @@ var FigureView = widgets.DOMWidgetView.extend({
1338213382
* necessary
1338313383
*/
1338413384
getFullLayout: function () {
13385-
return _.mergeWith(this.el._fullLayout, this.el.layout,
13385+
return _.mergeWith({}, this.el._fullLayout, this.el.layout,
1338613386
fullMergeCustomizer);
1338713387
},
1338813388

@@ -14337,8 +14337,10 @@ function createDeltaObject(fullObj, removeObj) {
1433714337
// the special case handling of this method
1433814338
res[p] = createDeltaObject(fullVal, {});
1433914339

14340-
} else if (fullVal !== undefined) {
14341-
// No recursion necessary, Just keep value from fullObj
14340+
} else if (fullVal !== undefined &&
14341+
typeof fullVal !== 'function') {
14342+
// No recursion necessary, Just keep value from fullObj.
14343+
// But skip values with function type
1434214344
res[p] = fullVal;
1434314345
}
1434414346
}

Diff for: plotlywidget/static/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)