use delete for removing events after removing the final listener

pull/22966/head
rick 2010-06-28 18:33:21 -07:00 committed by Ryan Dahl
parent abd3f8a02a
commit c9e505791a
1 changed files with 3 additions and 1 deletions

View File

@ -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;