Skip to content

Commit

Permalink
Update listener.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy Brauner authored Sep 13, 2023
1 parent 407e37d commit 549a1d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dom/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 549a1d4

Please sign in to comment.