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
1
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 0.0.100 to 1.1.3

2

dist/index.d.ts

@@ -13,3 +13,3 @@ /**

*/
declare const createEventListener: <T extends HTMLElement>(eventName: keyof WindowEventMap, handler: (event: Event) => void, targets?: Window | T) => [add: (el: Window | T) => void, remove: (el: Window | T) => void];
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];
export default createEventListener;

@@ -16,8 +16,7 @@ import { onMount, onCleanup } from "solid-js";

const add = (target) => target.addEventListener && target.addEventListener(eventName, handler);
const remove = (target) => target.removeEventListener &&
target.removeEventListener(eventName, handler);
onMount(() => Array.isArray(targets) ? targets.forEach(add) : add(targets));
onCleanup(() => Array.isArray(targets) ? targets.forEach(remove) : remove(targets));
const remove = (target) => target.removeEventListener && target.removeEventListener(eventName, handler);
onMount(() => (Array.isArray(targets) ? targets.forEach(add) : add(targets)));
onCleanup(() => (Array.isArray(targets) ? targets.forEach(remove) : remove(targets)));
return [add, remove];
};
export default createEventListener;
{
"name": "@solid-primitives/event-listener",
"version": "0.0.100",
"version": "1.1.3",
"description": "Primitive to manage creating event listeners.",

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

},
"dependencies": {
"solid-js": "^1.0.3"
"peerDependencies": {
"solid-js": "^1.0.7"
},

@@ -43,2 +43,2 @@ "jest": {

}
}
}

@@ -12,3 +12,4 @@ # @solid-primitives/event-listener

```ts
createEventListener("mouseDown", () => console.log("Click"), document.getElementById("mybutton"))
const [listener] = createEventListener("mouseDown", () => console.log("Click"), document.getElementById("mybutton"))
<button use:listener>Click me</button>
```

@@ -15,0 +16,0 @@

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