summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeremy Martin <jmar777@gmail.com>2013-11-22 09:17:16 -0500
committerBen Noordhuis <info@bnoordhuis.nl>2013-11-22 17:42:34 +0100
commit71aabedad422748e67d1aab18742d03b829d95c9 (patch)
tree93b5b859f343a81c1ffd3b7e96ea0ac3f22f9068 /lib
parenta34bbaf31bd327a616adb3ef670174228924a80a (diff)
downloadnodejs-71aabedad422748e67d1aab18742d03b829d95c9.tar.gz
nodejs-71aabedad422748e67d1aab18742d03b829d95c9.tar.bz2
nodejs-71aabedad422748e67d1aab18742d03b829d95c9.zip
events: fix TypeError in removeAllListeners
Check that `listeners` is actually an array before trying to manipulate it because it won't be if no regular event listeners have been registered yet but there are 'removeListener' event listeners.
Diffstat (limited to 'lib')
-rw-r--r--lib/events.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/events.js b/lib/events.js
index f43df093d..781748ba8 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -263,7 +263,7 @@ EventEmitter.prototype.removeAllListeners = function(type) {
if (typeof listeners === 'function') {
this.removeListener(type, listeners);
- } else {
+ } else if (Array.isArray(listeners)) {
// LIFO order
while (listeners.length)
this.removeListener(type, listeners[listeners.length - 1]);