Skip to content

Commit

Permalink
Also consider window
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Sep 15, 2021
1 parent 5d8ee19 commit 5656db8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/web-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ let online = true
const isOnline = () => online

// For node and React Native, `add/removeEventListener` doesn't exist on window.
const onWindowEvent = (hasWindow && addEventListener) || noop
const onWindowEvent = hasWindow
? (...args: Parameters<typeof window.addEventListener>) =>
window.addEventListener(...args)
: noop
const onDocumentEvent = hasDocument
? (...args: Parameters<typeof document.addEventListener>) =>
document.addEventListener(...args)
Expand Down

0 comments on commit 5656db8

Please sign in to comment.