Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Incompatabile with nodejs 6.9.1: makeZoneAwareRemoveAllListeners addes 'undefined' arguments to real removeAllListeners calls #518

@KrauseStefan

Description

@KrauseStefan

zone.js wrappes the removeAllListeners call from node.js but breaks compatibility with the real version.

This happens because zone.js parsed undefined arguments to the real call when none should be.
This causes the line highlighted below to fail since node.js tests on arguments.length

link to the faulting line in utils.ts:
https://github.com/angular/zone.js/blob/master/lib/common/utils.ts#L293

snippet form events.js in node 6.9.1

// ...
EventEmitter.prototype.removeAllListeners =
    function removeAllListeners(type) {
      var listeners, events;

      events = this._events;
      if (!events)
        return this;

      // not listening for removeListener, no need to emit
      if (!events.removeListener) {
        if (arguments.length === 0) { // <--- length will always be 2, since undefined is always passed
          this._events = new EventHandlers();
          this._eventsCount = 0;
        } else if (events[type]) {
          if (--this._eventsCount === 0)
            this._events = new EventHandlers();
          else
            delete events[type];
        }
        return this;
      }
// ...

The function is used by xml2js to remove all event listeners by calling:
removeAllListeners() without arguments

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions