Permalink
Browse files

Merge pull request #25 from hij1nx/onAny

Fixes and additional test coverage for .onAny()
  • Loading branch information...
2 parents e2358dd + 7265ce7 commit 255ef0ec3cf88b2e9cbacb8dbebde746f400b20d Hij1nx - Nodejitsu committed Jul 28, 2011
Showing with 130 additions and 140 deletions.
  1. +8 −5 lib/eventemitter2.js
  2. +122 −135 test/wildcardEvents/all.js
View
@@ -166,14 +166,19 @@
this._events || this.init();
var type = arguments[0];
+ this.event = type;
+
// If there is no 'error' event listener then throw.
if (type === 'newListener') {
- if(!this._events.newListener) { return false; }
+ if (!this._events.newListener) { return false; }
}
// Loop through the *_allListenerFn* functions and invoke them.
if (this._all) {
+ var l = arguments.length;
+ var args = new Array(l - 1);
+ for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
for (i = 0, l = this._all.length; i < l; i++) {
this._all[i].apply(this, args);
}
@@ -193,7 +198,6 @@
var handler;
if(this.wildcard) {
- this.event = type;
handler = [];
var ns = type.split(this.delimiter);
searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
@@ -203,10 +207,10 @@
}
if (typeof handler === 'function') {
- if(arguments.length === 1) {
+ if (arguments.length === 1) {
handler.call(this);
}
- else if(arguments.length > 1)
+ else if (arguments.length > 1)
switch (arguments.length) {
case 2:
handler.call(this, arguments[1]);
@@ -224,7 +228,6 @@
return true;
}
else if (handler) {
-
var l = arguments.length;
var args = new Array(l - 1);
for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
Oops, something went wrong.

0 comments on commit 255ef0e

Please sign in to comment.