hd-utils
Version:
A handy utils for modern JS developers
12 lines (11 loc) • 343 B
JavaScript
/**
* @description will check if the passed object accepts addEventListener and add it.
* @example addEventListener(event.target, "touchend", preventDefault, { passive: false });
*/
export default function addEventListener(obj,
//@ts-ignore
...args) {
if (obj && obj.addEventListener) {
obj.addEventListener(...args);
}
}