diff --git a/src/style/style.js b/src/style/style.js index abc8d93ce2e..d70f329782c 100644 --- a/src/style/style.js +++ b/src/style/style.js @@ -1143,9 +1143,16 @@ class Style extends Evented { this._spriteRequest = null; } rtlTextPluginEvented.off('pluginAvailable', this._rtlTextPluginCallback); + for (const layerId in this._layers) { + const layer: StyleLayer = this._layers[layerId]; + layer.setEventedParent(null); + } for (const id in this.sourceCaches) { this.sourceCaches[id].clearTiles(); + this.sourceCaches[id].setEventedParent(null); } + this.imageManager.setEventedParent(null); + this.setEventedParent(null); this.dispatcher.remove(); } diff --git a/src/util/actor.js b/src/util/actor.js index 4347918ef06..0095c6de136 100644 --- a/src/util/actor.js +++ b/src/util/actor.js @@ -190,6 +190,7 @@ class Actor { } remove() { + this.invoker.remove(); this.target.removeEventListener('message', this.receive, false); } } diff --git a/src/util/throttled_invoker.js b/src/util/throttled_invoker.js index 0fc3a614dae..ca1b97bfce1 100644 --- a/src/util/throttled_invoker.js +++ b/src/util/throttled_invoker.js @@ -36,6 +36,11 @@ class ThrottledInvoker { } } } + + remove() { + delete this._channel; + this._callback = () => {}; + } } export default ThrottledInvoker;