From abd4aacc8c47a251f069a66652434ca65f278c2a Mon Sep 17 00:00:00 2001 From: Sceat <11330271+Sceat@users.noreply.github.com> Date: Tue, 5 May 2020 20:37:51 +0200 Subject: [PATCH] remove implicit once https://github.com/websockets/ws/pull/1754#issuecomment-624228689 --- lib/event-target.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/event-target.js b/lib/event-target.js index 9eb13f2c2..b5a5de39a 100644 --- a/lib/event-target.js +++ b/lib/event-target.js @@ -116,26 +116,22 @@ const EventTarget = { */ addEventListener(method, listener, options = {}) { if (typeof listener !== 'function') return; - const { once } = options; function onMessage(data) { listener.call(this, new MessageEvent(data, this)); - if (once) this.removeListener(method, listener); + if (options.once) this.removeListener(method, listener); } function onClose(code, message) { listener.call(this, new CloseEvent(code, message, this)); - if (once) this.removeListener(method, listener); } function onError(error) { listener.call(this, new ErrorEvent(error, this)); - if (once) this.removeListener(method, listener); } function onOpen() { listener.call(this, new OpenEvent(this)); - if (once) this.removeListener(method, listener); } if (method === 'message') {