Huge News!Announcing our $40M Series B led by Abstract Ventures.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 4.0.1 to 5.0.0

4

index.d.ts

@@ -12,4 +12,4 @@ import type { ParseSelector } from 'typed-query-selector/parser.d.js';

*/
declare function delegate<Selector extends string, TElement extends Element = ParseSelector<Selector, HTMLElement>, TEventType extends EventType = EventType>(base: EventTarget | Document | Iterable<Element> | string, selector: Selector, type: TEventType, callback: DelegateEventHandler<GlobalEventHandlersEventMap[TEventType], TElement>, options?: DelegateOptions): AbortController;
declare function delegate<TElement extends Element = HTMLElement, TEventType extends EventType = EventType>(base: EventTarget | Document | Iterable<Element> | string, selector: string, type: TEventType, callback: DelegateEventHandler<GlobalEventHandlersEventMap[TEventType], TElement>, options?: DelegateOptions): AbortController;
declare function delegate<Selector extends string, TElement extends Element = ParseSelector<Selector, HTMLElement>, TEventType extends EventType = EventType>(base: EventTarget | Document | Iterable<Element> | string, selector: Selector, type: TEventType, callback: DelegateEventHandler<GlobalEventHandlersEventMap[TEventType], TElement>, options?: DelegateOptions): void;
declare function delegate<TElement extends Element = HTMLElement, TEventType extends EventType = EventType>(base: EventTarget | Document | Iterable<Element> | string, selector: string, type: TEventType, callback: DelegateEventHandler<GlobalEventHandlersEventMap[TEventType], TElement>, options?: DelegateOptions): void;
export default delegate;

@@ -42,18 +42,9 @@ /** Keeps track of raw listeners added to the base elements to avoid duplication */

function delegate(base, selector, type, callback, options) {
const internalController = new AbortController();
const listenerOptions = typeof options === 'object' ? options : { capture: options };
// Drop unsupported `once` option https://github.com/fregante/delegate-it/pull/28#discussion_r863467939
delete listenerOptions.once;
if (listenerOptions.signal) {
if (listenerOptions.signal.aborted) {
internalController.abort();
return internalController;
}
listenerOptions.signal.addEventListener('abort', () => {
internalController.abort();
});
const { signal } = listenerOptions;
if (signal?.aborted) {
return;
}
else {
listenerOptions.signal = internalController.signal;
}
// Handle Selector-based usage

@@ -68,3 +59,3 @@ if (typeof base === 'string') {

}
return internalController;
return;
}

@@ -87,7 +78,6 @@ // `document` should never be the base, it's just an easy way to define "global event listeners"

}
internalController.signal.addEventListener('abort', () => {
signal?.addEventListener('abort', () => {
editLedger(false, baseElement, callback, setup);
});
return internalController;
}
export default delegate;
{
"name": "delegate-it",
"version": "4.0.1",
"version": "5.0.0",
"description": "Lightweight and modern event delegation in the browser",

@@ -5,0 +5,0 @@ "keywords": [

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