From 549a1d402bf1eab1ac8afbb5ed1cd9e01f1a4894 Mon Sep 17 00:00:00 2001 From: Willy Brauner Date: Wed, 13 Sep 2023 11:09:51 +0200 Subject: [PATCH] Update listener.ts --- src/dom/listener.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dom/listener.ts b/src/dom/listener.ts index d08cba6..4156989 100644 --- a/src/dom/listener.ts +++ b/src/dom/listener.ts @@ -23,9 +23,9 @@ export function listen< options?: boolean | AddEventListenerOptions, ): () => void { if (typeof event === "string") event = [event] - for (let name of event) obj.addEventListener(name, callback, options) + for (let name of event) obj?.addEventListener(name, callback, options) return () => { - for (let name of event) obj.removeEventListener(name, callback, options) + for (let name of event) obj?.removeEventListener(name, callback, options) } }