UNPKG

@grail-ui/svelte

Version:

[![NPM](https://img.shields.io/npm/v/@grail-ui/svelte)](https://www.npmjs.com/package/@grail-ui/svelte) [![minified](https://img.shields.io/bundlephobia/min/@grail-ui/svelte)](https://bundlephobia.com/package/@grail-ui/svelte) [![minified + zipped](https:

11 lines (10 loc) 419 B
/** * Adds an event listener to an element, and returns a function to remove it. */ export function addEventListener(target, event, handler, options) { const events = Array.isArray(event) ? [...event] : [event]; events.forEach((_event) => target.addEventListener(_event, handler, options)); return () => { events.forEach((_event) => target.removeEventListener(_event, handler, options)); }; }