aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-11-15 00:50:44 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-11-15 00:50:44 +0100
commit1205d555835772da4e43e0dc8bd60ac449c74ac2 (patch)
tree201fe5807ca6ac1fce60bf4746795aeaf5774ca3 /static
parentcleanup (diff)
downloadcalp-1205d555835772da4e43e0dc8bd60ac449c74ac2.tar.gz
calp-1205d555835772da4e43e0dc8bd60ac449c74ac2.tar.xz
Add HTMLElement.getListeners.
Diffstat (limited to 'static')
-rw-r--r--static/lib.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/static/lib.ts b/static/lib.ts
index 1dfd83f4..8845f37b 100644
--- a/static/lib.ts
+++ b/static/lib.ts
@@ -18,7 +18,8 @@ declare global {
interface HTMLElement {
_addEventListener: (name: string, proc: (e: Event) => void) => void
- listeners: Record<string, ((e: Event) => void)[]>
+ listeners: Map<string, ((e: Event) => void)[]>
+ getListeners: () => Map<string, ((e: Event) => void)[]>
}
interface Date {
@@ -43,11 +44,15 @@ declare global {
HTMLElement.prototype._addEventListener = HTMLElement.prototype.addEventListener;
HTMLElement.prototype.addEventListener = function(name: string, proc: (e: Event) => void) {
- if (!this.listeners) this.listeners = {};
- if (!this.listeners[name]) this.listeners[name] = [];
- this.listeners[name].push(proc);
+ if (!this.listeners) this.listeners = new Map
+ if (!this.listeners.get(name)) this.listeners.set(name, []);
+ /* Force since we ensure a value just above */
+ this.listeners.get(name)!.push(proc);
return this._addEventListener(name, proc);
};
+HTMLElement.prototype.getListeners = function() {
+ return this.listeners;
+}
/* ----- Date Extensions ---------------------------- */