diff --git a/src/util.ts b/src/util.ts index fc2a135e..76d6778c 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,23 +1,5 @@ export const isClient = typeof window === 'object'; -export const on = (obj: any, ...args: any[]) => { - try { - obj.addEventListener(...args); - } catch (error) { - handleError(error); - } -}; +export const on = (obj: any, ...args: any[]) => obj && obj.addEventListener(...args); -export const off = (obj: any, ...args: any[]) => { - try { - obj.removeEventListener(...args); - } catch (error) { - handleError(error); - } -}; - -const handleError = (error: any) => { - if (process.env.NODE_ENV !== 'production') { - console.error(error); - } -}; +export const off = (obj: any, ...args: any[]) => obj && obj.removeEventListener(...args);