browserify / browser-resolve

resolve function which support the browser field in package.json

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

events.EventEmitter.removeAllListeners removes no listeners if no arguments are passed

segrey opened this issue · comments

Actuall EventEmitter.prototype.removeAllListeners implementation looks like this:

EventEmitter.prototype.removeAllListeners = function(type) {
  if (arguments.length === 0) {
    this._events = {};
    return this;
  }

  // does not use listeners(), so no side effect of creating _events[type]
  if (type && this._events && this._events[type]) this._events[type] = null;
  return this;
};

It could be found in ./lib/events.js of http://nodejs.org/dist/v0.8.18/node-v0.8.18.tar.gz.

But node-browserify/builtins/events.js has following implementation:

EventEmitter.prototype.removeAllListeners = function(type) {
  // does not use listeners(), so no side effect of creating _events[type]
  if (type && this._events && this._events[type]) this._events[type] = null;
  return this;
};

Such difference results in unexpected behavior of emitter.removeAllListeners() method call in broserified version of Node app.
Expected: All listeners of all types are removed.
Actual: No listeners removed.