From 1e2e1c83ea93c3c019daed29e217d37e84dad882 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Wed, 8 Jan 2020 13:26:56 +0100 Subject: [PATCH] fix(Map): rm moveend listener from setMaxBounds (#6958) Calling `map.setMapBounds`, adds the `"moveend"` event listener `_panInsideMaxBounds`. Previously, this did not get cleaned up via `remove`. --- spec/suites/map/MapSpec.js | 2 +- src/map/Map.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/suites/map/MapSpec.js b/spec/suites/map/MapSpec.js index e66f54aea..fc8c76f2a 100644 --- a/spec/suites/map/MapSpec.js +++ b/spec/suites/map/MapSpec.js @@ -72,7 +72,7 @@ describe("Map", function () { it("does not throw if removed during animation", function () { var container = document.createElement('div'), - map = new L.Map(container).setView([0, 0], 1); + map = new L.Map(container).setView([0, 0], 1).setMaxBounds([[0, 1], [2, 3]]); // Force creation of animation proxy, // otherwise browser checks disable it diff --git a/src/map/Map.js b/src/map/Map.js index 5a66c9a57..0eb1e372c 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -752,6 +752,7 @@ export var Map = Evented.extend({ remove: function () { this._initEvents(true); + this.off('moveend', this._panInsideMaxBounds); if (this._containerId !== this._container._leaflet_id) { throw new Error('Map container is being reused by another instance');