diff --git a/src/utils/event.js b/src/utils/event.js index 932b83e..28cfe93 100644 --- a/src/utils/event.js +++ b/src/utils/event.js @@ -1,4 +1,7 @@ export function on(el, eventName, callback, opts) { + if(!el){ + return; + } opts = opts || false; if (el.addEventListener) { el.addEventListener(eventName, callback, opts); @@ -10,6 +13,9 @@ export function on(el, eventName, callback, opts) { } export function off(el, eventName, callback, opts) { + if(!el){ + return; + } opts = opts || false; if (el.removeEventListener) { el.removeEventListener(eventName, callback, opts);