From e93af8b577dc13f324c6cbc9a2f204c760505917 Mon Sep 17 00:00:00 2001 From: rr- Date: Mon, 13 Jun 2016 20:11:17 +0200 Subject: [PATCH] client/events: add experimental EventTarget --- client/js/events.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/js/events.js b/client/js/events.js index 0dd010a1..177ad27f 100644 --- a/client/js/events.js +++ b/client/js/events.js @@ -36,6 +36,19 @@ function notify(messageClass, message) { } } +class EventTarget { + constructor() { + this.eventTarget = document.createDocumentFragment(); + for (let method of [ + 'addEventListener', + 'dispatchEvent', + 'removeEventListener' + ]) { + this[method] = this.eventTarget[method].bind(this.eventTarget); + } + } +}; + module.exports = { Success: 'success', Error: 'error', @@ -47,4 +60,5 @@ module.exports = { notify: notify, listen: listen, unlisten: unlisten, + EventTarget: EventTarget, };