From c9e505791a7eae47a0c3e6bcbeb33553ac3b85cb Mon Sep 17 00:00:00 2001 From: rick Date: Mon, 28 Jun 2010 18:33:21 -0700 Subject: [PATCH] use delete for removing events after removing the final listener --- lib/events.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/events.js b/lib/events.js index ee17a22c7e7..fa680ad4557 100644 --- a/lib/events.js +++ b/lib/events.js @@ -91,8 +91,10 @@ process.EventEmitter.prototype.removeListener = function (type, listener) { var i = list.indexOf(listener); if (i < 0) return this; list.splice(i, 1); + if (list.length == 0) + delete this._events[type]; } else if (this._events[type] === listener) { - this._events[type] = null; + delete this._events[type]; } return this;