@bleckert/delegate-event
Advanced tools
Comparing version 1.0.0 to 1.0.1
function $cf838c15c8b009ba$export$2e2bcd8739ae039(event, selector, fn, context = document) { | ||
function handler(e) { | ||
const el = e.target.closest(selector); | ||
if (el) fn(e, el); | ||
if (el) { | ||
const result = fn(e, el); | ||
if (result === false) e.preventDefault(); | ||
} | ||
} | ||
context.addEventListener(event, (e)=>handler); | ||
context.addEventListener(event, (e)=>handler(e)); | ||
return ()=>context.removeEventListener(event, handler); | ||
@@ -8,0 +11,0 @@ } |
{ | ||
"name": "@bleckert/delegate-event", | ||
"repository": "https://github.com/tbleckert/delegate-event", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Simple DOM event delegation", | ||
@@ -6,0 +6,0 @@ "source": "src/index.js", |
@@ -16,3 +16,3 @@ <h1 align="center"> | ||
<a href="https://bundlephobia.com/result?p=@bleckert/delegate-event"> | ||
<img src="https://img.shields.io/bundlephobia/minzip/@bleckert/events?style=for-the-badge" /> | ||
<img src="https://img.shields.io/bundlephobia/minzip/@bleckert/delegate-event?style=for-the-badge" /> | ||
</a> | ||
@@ -19,0 +19,0 @@ <a href="https://github.com/sponsors/tbleckert"> |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3238
13
0