New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

delegate-it

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delegate-it - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

24

index.js

@@ -27,2 +27,15 @@ /** Keeps track of raw listeners added to the base elements to avoid duplication */

}
function safeClosest(event, selector) {
let target = event.target;
if (target instanceof Text) {
target = target.parentElement;
}
if (target instanceof Element && event.currentTarget instanceof Element) {
// `.closest()` may match ancestors of `currentTarget` but we only need its children
const closest = target.closest(selector);
if (closest && event.currentTarget.contains(closest)) {
return closest;
}
}
}
/**

@@ -52,10 +65,5 @@ * Delegates event to a selector.

const listenerFn = (event) => {
const delegateTarget = event.target.closest(selector);
if (!delegateTarget) {
return;
}
event.delegateTarget = delegateTarget;
// Closest may match elements outside of the currentTarget
// so it needs to be limited to elements inside it
if (event.currentTarget.contains(event.delegateTarget)) {
const delegateTarget = safeClosest(event, selector);
if (delegateTarget) {
event.delegateTarget = delegateTarget;
callback.call(baseElement, event);

@@ -62,0 +70,0 @@ }

{
"name": "delegate-it",
"version": "2.0.1",
"version": "2.0.2",
"description": "Lightweight event delegation",

@@ -32,7 +32,6 @@ "keywords": [

"rules": {
"max-params": 0,
"prefer-rest-params": 0,
"import/extensions": 0,
"unicorn/import-index": 0,
"import/no-useless-path-segments": 0
"import/extensions": "off",
"import/no-useless-path-segments": "off",
"max-params": "off",
"unicorn/import-index": "off"
}

@@ -47,4 +46,4 @@ },

"typescript": "^4.0.2",
"xo": "^0.33.1"
"xo": "^0.34.2"
}
}
# delegate-it [![][badge-gzip]][link-bundlephobia]
[badge-gzip]: https://img.shields.io/bundlephobia/minzip/delegate-it.svg?label=gzipped
[link-bundlephobia]: https://bundlephobia.com/result?p=delegate-it
[badge-gzip]: https://img.shields.io/bundlephobia/minzip/delegate-it.svg?label=gzipped
[link-bundlephobia]: https://bundlephobia.com/result?p=delegate-it

@@ -6,0 +6,0 @@ > Lightweight event delegation

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