Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-primitives/event-listener

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/event-listener - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

3

dist/index.d.ts

@@ -7,2 +7,3 @@ /**

* @param element - HTML element to bind the event to
* @param options - *useCapture* boolean or an object that specifies characteristics about the event listener.
*

@@ -14,3 +15,3 @@ * @example

*/
declare const createEventListener: <T extends HTMLElement>(eventName: keyof WindowEventMap, handler: (event: Event) => void, targets?: Window | T | T[]) => [add: (el: Window | T) => void, remove: (el: Window | T) => void];
declare const createEventListener: <T extends HTMLElement, E extends keyof WindowEventMap>(eventName: E, handler: (event: WindowEventMap[E]) => void, targets?: Window | T | T[], options?: boolean | AddEventListenerOptions | undefined) => readonly [add: (el: Window | T) => void, remove: (el: Window | T) => void];
export default createEventListener;

@@ -8,2 +8,3 @@ import { onMount, onCleanup } from "solid-js";

* @param element - HTML element to bind the event to
* @param options - *useCapture* boolean or an object that specifies characteristics about the event listener.
*

@@ -15,5 +16,7 @@ * @example

*/
const createEventListener = (eventName, handler, targets = window) => {
const add = (target) => target.addEventListener && target.addEventListener(eventName, handler);
const remove = (target) => target.removeEventListener && target.removeEventListener(eventName, handler);
const createEventListener = (eventName, handler, targets = window, options) => {
const add = (target) => target.addEventListener &&
target.addEventListener(eventName, handler, options);
const remove = (target) => target.removeEventListener &&
target.removeEventListener(eventName, handler, options);
onMount(() => (Array.isArray(targets) ? targets.forEach(add) : add(targets)));

@@ -20,0 +23,0 @@ onCleanup(() => (Array.isArray(targets) ? targets.forEach(remove) : remove(targets)));

{
"name": "@solid-primitives/event-listener",
"version": "1.1.3",
"version": "1.1.4",
"description": "Primitive to manage creating event listeners.",

@@ -5,0 +5,0 @@ "author": "David Di Biase <dave.dibiase@gmail.com>",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc