Skip to content

Commit

Permalink
Fix return value for wildcard emit #165
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyksv committed Apr 24, 2016
1 parent 3d148d7 commit 69b88d7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/eventemitter2.js
Expand Up @@ -297,7 +297,7 @@
handler[i].call(this, type, arguments[1], arguments[2]);
break;
default:
handler[i].apply(this, args);
this._all[i].apply(this, args);
}
}
}
Expand All @@ -308,6 +308,9 @@
searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
} else {
handler = this._events[type];
// need to make copy of handlers because list can change in the middle
// of emit call
if (isArray(handler)) handler = handler.slice();
}

if (typeof handler === 'function') {
Expand All @@ -329,9 +332,6 @@
}
return true;
} else if (handler && handler.length) {
// need to make copy of handlers because list can change in the middle
// of emit call
handler = handler.slice();
if (al > 3) {
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
Expand All @@ -352,6 +352,7 @@
handler[i].apply(this, args);
}
}
return true;
} else if (!this._all && type === 'error') {
if (arguments[1] instanceof Error) {
throw arguments[1]; // Unhandled 'error' event
Expand Down

0 comments on commit 69b88d7

Please sign in to comment.