Skip to content

Commit

Permalink
Update listener.ts (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Willy Brauner <[email protected]>
  • Loading branch information
willybrauner and Willy Brauner authored Mar 7, 2024
1 parent db4ece1 commit 3e8c4af
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 3e8c4af

Please sign in to comment.