/** * Tuple list of `[eventName, listener]` pairs. * * IMPORTANT: instances passed to {@link addEventListeners} are mutated in * place — the original `listener` is replaced by its bound counterpart so that * {@link removeEventListeners} can deregister the exact same function * reference. Treat each array as private to a single component instance and do * not share it across instances. */ export type EventsAndListeners = [string, EventListener][]; /** * Adds a set of event listeners to the given target and binds each listener to * the provided `context`. * * Side effect: each `events[i][1]` is overwritten with the bound listener so * that a later call to {@link removeEventListeners} with the same array * removes the exact reference that was registered. Without this, every * `listener.bind(context)` would produce a new function and * `removeEventListener` would silently no-op, leaking listeners on `document`, * `window`, or trigger elements when the component is destroyed. * @param {EventsAndListeners} events - The events and listeners to add. Mutated in place. * @param {Element | Window | Document | ChildNode} target - The target to attach the listeners to. * @param {T} context - The class context to bind the listeners to. */ export declare function addEventListeners(events: EventsAndListeners, target: Element | Window | Document | ChildNode, context: T): void; /** * Removes the listeners previously registered with {@link addEventListeners}. * * Relies on the bound references stored back into `events[i][1]` by * {@link addEventListeners}; if the listener references don't match what was * registered, `removeEventListener` will silently no-op. * @param {EventsAndListeners} events - The events and listeners to remove. * @param {Element | Window | Document | ChildNode} target - The target to detach the listeners from. * @param {T} _context - Unused; kept for symmetry with {@link addEventListeners}. */ export declare function removeEventListeners(events: EventsAndListeners, target: Element | Window | Document | ChildNode, _context: T): void;