Skip to content

Commit

Permalink
Prevent shallow copy of default options (multiple charts) (#240)
Browse files Browse the repository at this point in the history
* Prevent shallow copy of default options (multiple charts)

closes: #238

* Update control.js
  • Loading branch information
Raruto authored Apr 23, 2023
1 parent 078c555 commit bfafa91
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
*/
initialize: function(opts) {

opts = L.setOptions(this, opts);
// opts = L.setOptions(this, opts);

// Fixes: https://github.com/Raruto/leaflet-elevation/pull/240
opts = L.setOptions(this, L.extend({}, structuredClone(Options), opts)); // "deep copy" nested objects (multiple charts)

this._data = [];
this._layers = L.featureGroup();
Expand Down

0 comments on commit bfafa91

Please sign in to comment.