faye/faye-websocket-node

Event listeners are broken

Closed this issue · 3 comments

Adding event listeners with addEventListener is broken.

In api.js, e.g. eventType is not defined (must be "type"?).

  addEventListener: function(type, listener, useCapture) {
    this._listeners = this._listeners || {};
    var list = this._listeners[eventType] = this._listeners[eventType] || [];
    list.push(listener);
  },

And, the behavior of listeners added with addEventListener seems to be different from on... function:

conn.onmessage = function(event) {
  console.log(event.data);
}
conn.addEventListener('message', function(event) {
  // event is undefined here
}

This should be consistent.

Thanks -- looks like I refactored something a little too hastily. Will fix later today.

Fixed in 85a11d5

Fix now released to npm in version 0.1.1.