Replace goog.events.Event/EventTarget system with our own

This also removes goog.events.listen, goog.events.unlisten,
goog.events.unlistenByKey and goog.events.BrowserEvent.
This commit is contained in:
Andreas Hocevar
2016-01-29 16:29:46 +01:00
parent d87482e415
commit 3f2d79b7fe
110 changed files with 1143 additions and 733 deletions

View File

@@ -114,7 +114,7 @@ describe('ol.collection', function() {
it('fires a remove event', function() {
var collection = new ol.Collection([0, 1, 2]);
var cb = sinon.spy();
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb);
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb);
expect(collection.remove(1)).to.eql(1);
expect(cb).to.be.called();
expect(cb.lastCall.args[0].element).to.eql(1);
@@ -137,10 +137,10 @@ describe('ol.collection', function() {
it('does dispatch events', function() {
var collection = new ol.Collection(['a', 'b']);
var added, removed;
goog.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
added = e.element;
});
goog.events.listen(
ol.events.listen(
collection, ol.CollectionEventType.REMOVE, function(e) {
removed = e.element;
});
@@ -154,7 +154,7 @@ describe('ol.collection', function() {
it('does dispatch events', function() {
var collection = new ol.Collection(['a']);
var removed;
goog.events.listen(
ol.events.listen(
collection, ol.CollectionEventType.REMOVE, function(e) {
removed = e.element;
});
@@ -167,7 +167,7 @@ describe('ol.collection', function() {
it('does dispatch events', function() {
var collection = new ol.Collection([0, 2]);
var added;
goog.events.listen(
ol.events.listen(
collection, ol.CollectionEventType.ADD, function(e) {
added = e.element;
});
@@ -179,7 +179,7 @@ describe('ol.collection', function() {
describe('setAt beyond end', function() {
it('triggers events properly', function() {
var added = [];
goog.events.listen(
ol.events.listen(
collection, ol.CollectionEventType.ADD, function(e) {
added.push(e.element);
});
@@ -200,7 +200,7 @@ describe('ol.collection', function() {
beforeEach(function() {
collection = new ol.Collection([0, 1, 2]);
cb = sinon.spy();
goog.events.listen(collection, 'change:length', cb);
ol.events.listen(collection, 'change:length', cb);
});
describe('insertAt', function() {
@@ -229,7 +229,7 @@ describe('ol.collection', function() {
it('triggers add when pushing', function() {
var collection = new ol.Collection();
var elem;
goog.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
elem = e.element;
});
collection.push(1);
@@ -246,8 +246,8 @@ describe('ol.collection', function() {
});
describe('setAt', function() {
it('triggers remove', function() {
goog.events.listen(collection, ol.CollectionEventType.ADD, cb1);
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb2);
ol.events.listen(collection, ol.CollectionEventType.ADD, cb1);
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb2);
collection.setAt(0, 2);
expect(cb2.lastCall.args[0].element).to.eql(1);
expect(cb1.lastCall.args[0].element).to.eql(2);
@@ -255,7 +255,7 @@ describe('ol.collection', function() {
});
describe('pop', function() {
it('triggers remove', function() {
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb1);
ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb1);
collection.pop();
expect(cb1.lastCall.args[0].element).to.eql(1);
});
@@ -273,7 +273,7 @@ describe('ol.collection', function() {
it('fires events', function() {
var collection = new ol.Collection();
var elems = [];
goog.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
elems.push(e.element);
});
collection.extend([1, 2]);
@@ -284,6 +284,6 @@ describe('ol.collection', function() {
});
goog.require('goog.events');
goog.require('ol.events');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');