Refactor event manager to remove memory leaks

This commit is contained in:
Andreas Hocevar
2016-01-30 15:29:44 +01:00
parent d7497f9686
commit c51d717657
6 changed files with 207 additions and 151 deletions

View File

@@ -60,7 +60,7 @@ ol.control.Control = function(options) {
/**
* @protected
* @type {!Array.<?number>}
* @type {!Array.<ol.events.Key>}
*/
this.listenerKeys = [];
@@ -108,7 +108,7 @@ ol.control.Control.prototype.setMap = function(map) {
goog.dom.removeNode(this.element);
}
if (this.listenerKeys.length > 0) {
this.listenerKeys.forEach(/** @type {Function} */ (ol.events.unlistenByKey));
ol.events.unlistenByKey(this.listenerKeys);
this.listenerKeys.length = 0;
}
this.map_ = map;