aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/core.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed/js/core.js')
-rw-r--r--ext/mixed/js/core.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index b6ecb48b..330a30fb 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -236,6 +236,29 @@ class EventDispatcher {
}
}
+class EventListenerCollection {
+ constructor() {
+ this._eventListeners = [];
+ }
+
+ get size() {
+ return this._eventListeners.length;
+ }
+
+ addEventListener(node, type, listener, options) {
+ node.addEventListener(type, listener, options);
+ this._eventListeners.push([node, type, listener, options]);
+ }
+
+ removeAllEventListeners() {
+ if (this._eventListeners.length === 0) { return; }
+ for (const [node, type, listener, options] of this._eventListeners) {
+ node.removeEventListener(type, listener, options);
+ }
+ this._eventListeners = [];
+ }
+}
+
/*
* Default message handlers