Skip to content

Commit

Permalink
remove implicit once
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceat committed May 5, 2020
1 parent 697ed9b commit abd4aac
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/event-target.js
Expand Up @@ -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') {
Expand Down

0 comments on commit abd4aac

Please sign in to comment.