Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/4.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Aug 8, 2013
2 parents a707717 + 3470e51 commit 156af3d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
10 changes: 8 additions & 2 deletions EventEmitter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* EventEmitter v4.2.2 - git.io/ee
* EventEmitter v4.2.3 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
Expand Down Expand Up @@ -365,8 +365,14 @@
// If the listener returns true then it shall be removed from the event
// The function is executed either with a basic call or an apply if there is an args array
listener = listeners[key][i];

if (listener.once === true) {
this.removeListener(evt, listener.listener);
}

response = listener.listener.apply(this, args || []);
if (response === this._getOnceReturnValue() || listener.once === true) {

if (response === this._getOnceReturnValue()) {
this.removeListener(evt, listener.listener);
}
}
Expand Down
4 changes: 2 additions & 2 deletions EventEmitter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eventEmitter",
"description": "Event based JavaScript for the browser",
"version": "4.2.2",
"version": "4.2.3",
"main": [
"./EventEmitter.js"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wolfy87-eventemitter",
"version": "4.2.2",
"version": "4.2.3",
"description": "Event based JavaScript for the browser",
"main": "EventEmitter.js",
"directories": {
Expand Down
9 changes: 9 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@
ee.removeListener('foo', fn1);
assert.deepEqual(ee.flattenListeners(ee.getListeners('foo')), []);
});

test('can not cause infinite recursion', function () {
ee.addOnceListener('foo', function() {
counter += 1;
this.emitEvent('foo');
});
ee.trigger('foo');
assert.strictEqual(counter, 1);
});
});

suite('removeListener', function() {
Expand Down

0 comments on commit 156af3d

Please sign in to comment.