/** * @file * * Shared implementation of the delegated `on` / `off` helpers Obsidian adds to `Document.prototype` and * `HTMLElement.prototype`. As in Obsidian, every registration is kept on the target's own `_EVENTS` record, keyed by * event type, so it can be found and removed again. */ /** * A listener as the delegated helpers call it: with the target as `this`, the event, and the element that matched * the selector. * * @typeParam T - The event target's type, bound as the listener's `this`. */ export type DelegatedListener = (this: T, $event: Event, delegateTarget: HTMLElement) => unknown; /** * Removes every registration whose selector, listener and options are all identical to the ones given, detaching * each wrapper it added; does nothing when there is none. * * @param target - The target the listener was added to. * @param type - The event type the listener was registered for. * @param selector - The selector the listener was registered with. * @param listener - The original listener, as passed to {@link delegatedOn}. * @param options - The options the listener was registered with, compared by identity. */ export declare function delegatedOff(target: EventTarget, type: string, selector: string, listener: unknown, options?: AddEventListenerOptions | boolean): void; /** * Adds a delegated listener, as Obsidian does. Each event of `type` is matched with * `event.target.matchParent(selector, event.currentTarget)`: when the event target or one of its ancestors up to the * listening target matches, the listener is called with `target` as `this`, the event, and that element. Events * whose target has no `matchParent` (a text node, the document itself) are ignored. * * Every call adds a new registration, so registering the same listener twice calls it twice. * * @typeParam T - The event target's type, bound as the listener's `this`. * @param target - The target to listen on. * @param type - The event type to listen for. * @param selector - The CSS selector the event target, or an ancestor of it, must match. * @param listener - The listener to call. * @param options - Options passed on to `addEventListener`. */ export declare function delegatedOn(target: T, type: string, selector: string, listener: DelegatedListener, options?: AddEventListenerOptions | boolean): void;