Refactor event manager to remove memory leaks
This commit is contained in:
@@ -328,9 +328,9 @@ describe('ol.interaction.Modify', function() {
|
||||
beforeEach(function() {
|
||||
getListeners = function(feature, modify) {
|
||||
var listeners = ol.events.getListeners(
|
||||
feature, ol.events.EventType.CHANGE);
|
||||
feature, 'change');
|
||||
return listeners.filter(function(listener) {
|
||||
return listener.handler == modify;
|
||||
return listener.bindTo === modify;
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -378,7 +378,6 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
|
||||
@@ -286,14 +286,14 @@ describe('ol.layer.Group', function() {
|
||||
|
||||
var listeners = layerGroup.listenerKeys_[goog.getUid(layer)];
|
||||
expect(listeners.length).to.eql(2);
|
||||
expect(typeof listeners[0]).to.be('string');
|
||||
expect(typeof listeners[1]).to.be('string');
|
||||
expect(typeof listeners[0]).to.be('object');
|
||||
expect(typeof listeners[1]).to.be('object');
|
||||
|
||||
// remove the layer from the group
|
||||
layers.pop();
|
||||
expect(goog.object.getCount(layerGroup.listenerKeys_)).to.eql(0);
|
||||
expect(ol.events.listenersByKey_[listeners[0]]).to.be(undefined);
|
||||
expect(ol.events.listenersByKey_[listeners[1]]).to.be(undefined);
|
||||
expect(listeners[0].listener).to.be(undefined);
|
||||
expect(listeners[1].listener).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('ol.Observable', function() {
|
||||
it('returns a listener key', function() {
|
||||
var key = observable.on('foo', listener);
|
||||
|
||||
expect(typeof key).to.be('string');
|
||||
expect(typeof key).to.be('object');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -101,7 +101,7 @@ describe('ol.Observable', function() {
|
||||
it('returns a listener key', function() {
|
||||
var key = observable.once('foo', listener);
|
||||
|
||||
expect(typeof key).to.be('string');
|
||||
expect(typeof key).to.be('object');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user