diff --git a/lib/ws-browser.js b/lib/ws-browser.js index 63170852..153c4da0 100644 --- a/lib/ws-browser.js +++ b/lib/ws-browser.js @@ -4,7 +4,6 @@ const EventEmitter = require('events').EventEmitter; const serde = require('./serde'); -const common = require('./common'); const constants = require('./internal-constants'); const transportCommon = require('./transport-common'); @@ -22,7 +21,12 @@ class Transport extends EventEmitter { this._onMessage(message); }; - common.forwardMultipleEvents(this.socket, this, ['close', 'error']); + + ['close', 'error'].forEach((event) => { + this.socket.addEventListener(event, (...args) => { + this.emit(event, ...args); + }); + }); } // returns underlying socket.