UNPKG

22.9 kBTypeScriptView Raw
1/**
2 * Attach an event listener that will be called once whenever any of the specified event types are delivered to the given target.
3 *
4 * @param target - The target on which the event listener is attached.
5 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
6 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
7 * @param useCapture - Whether or not events of these types will be dispatched to the registered listener before being dispatched to any target beneath it in the DOM tree.
8 *
9 * @returns The provided listener when successfully attached; otherwise, `undefined`.
10 *
11 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
12 */
13declare function any(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): EventListenerOrEventListenerObject | null | undefined;
14/**
15 * Attach an event listener that will be called once whenever any of the specified event types are delivered to the given target.
16 *
17 * @param target - The target on which the event listener is attached.
18 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
19 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
20 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters|options object} specifying characteristics about the event listener.
21 *
22 * @returns The provided listener when successfully attached; otherwise, `undefined`.
23 *
24 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
25 */
26declare function any(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, options: AddEventListenerOptions): EventListenerOrEventListenerObject | null | undefined;
27/**
28 * Attach an event listener that will be called once whenever any of the specified event types are delivered to the given node from specific descendants.
29 *
30 * @param node - The node on which the event listener is attached.
31 * @param selector - A selector string to filter the descendants of the given node that trigger the event.
32 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
33 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
34 * @param useCapture - Whether or not events of these types will be dispatched to the registered listener before being dispatched to any target beneath it in the DOM tree.
35 *
36 * @returns The provided listener when successfully attached; otherwise, `undefined`.
37 *
38 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
39 */
40declare function any(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): EventListenerOrEventListenerObject | null | undefined;
41/**
42 * Attach an event listener that will be called once whenever any of the specified event types are delivered to the given node from specific descendants.
43 *
44 * @param node - The node on which the event listener is attached.
45 * @param selector - A selector string to filter the descendants of the given node that trigger the event.
46 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
47 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
48 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters|options object} specifying characteristics about the event listener.
49 *
50 * @returns The provided listener when successfully attached; otherwise, `undefined`.
51 *
52 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
53 */
54declare function any(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, options: AddEventListenerOptions): EventListenerOrEventListenerObject | null | undefined;
55/**
56 * Detach all event listeners of the specified event types from the given target.
57 *
58 * @param target - The target from which the event listener is detached.
59 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to detach.
60 *
61 * @returns `true` when successfully detached at least one listener; otherwise, `false`.
62 */
63declare function off(target: EventTarget, types: string): boolean;
64/**
65 * Detach an event listener of the specified event types from the given target.
66 *
67 * @param target - The target from which the event listener is detached.
68 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to detach.
69 * @param listener - The {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|event listener} to detach from the event target.
70 * @param useCapture - Whether or not the EventListener to be detached is registered as a capturing listener.
71 *
72 * @returns `true` when successfully detached at least one listener; otherwise, `false`.
73 */
74declare function off(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): boolean;
75/**
76 * Detach an event listener of the specified event types from the given target.
77 *
78 * @param target - The target from which the event listener is detached.
79 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to detach.
80 * @param listener - The {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|event listener} to detach from the event target.
81 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener#parameters|options object} specifying characteristics about the event listener.
82 *
83 * @returns `true` when successfully detached at least one listener; otherwise, `false`.
84 */
85declare function off(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, options: EventListenerOptions): boolean;
86/**
87 * Detach all event listeners of the specified event types from the given node for the specified selector.
88 *
89 * @param node - The node from which the event listener is detached.
90 * @param selector - A selector which should match the one used when attaching event listeners.
91 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to detach.
92 *
93 * @returns `true` when successfully detached at least one listener; otherwise, `false`.
94 */
95declare function off(node: Node, selector: string, types: string): boolean;
96/**
97 * Detach an event listener of the specified event types from the given node for the specified selector.
98 *
99 * @param node - The node from which the event listener is detached.
100 * @param selector - A selector which should match the one used when attaching event listeners.
101 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to detach.
102 * @param listener - The {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|event listener} to detach from the event target.
103 * @param useCapture - Whether or not the EventListener to be detached is registered as a capturing listener.
104 *
105 * @returns `true` when successfully detached at least one listener; otherwise, `false`.
106 */
107declare function off(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): boolean;
108/**
109 * Detach an event listener of the specified event types from the given node for the specified selector.
110 *
111 * @param node - The node from which the event listener is detached.
112 * @param selector - A selector which should match the one used when attaching event listeners.
113 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to detach.
114 * @param listener - The {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|event listener} to detach from the event target.
115 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener#parameters|options object} specifying characteristics about the event listener.
116 *
117 * @returns `true` when successfully detached at least one listener; otherwise, `false`.
118 */
119declare function off(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, options: EventListenerOptions): boolean;
120/**
121 * Attach an event listener that will be called whenever a specified event type is delivered to the given target.
122 *
123 * @param target - The target on which the event listener is attached.
124 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
125 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
126 * @param useCapture - Whether or not events of these types will be dispatched to the registered listener before being dispatched to any target beneath it in the DOM tree.
127 *
128 * @returns The provided listener when successfully attached; otherwise, `undefined`.
129 *
130 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
131 */
132declare function on(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): EventListenerOrEventListenerObject | null | undefined;
133/**
134 * Attach an event listener that will be called whenever a specified event type is delivered to the given target.
135 *
136 * @param target - The target on which the event listener is attached.
137 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
138 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
139 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters|options object} specifying characteristics about the event listener.
140 *
141 * @returns The provided listener when successfully attached; otherwise, `undefined`.
142 *
143 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
144 */
145declare function on(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, options: AddEventListenerOptions): EventListenerOrEventListenerObject | null | undefined;
146/**
147 * Attach an event listener that will be called whenever a specified event type is delivered to the given node from specific descendants.
148 *
149 * @param node - The node on which the event listener is attached.
150 * @param selector - A selector string to filter the descendants of the given node that trigger the event.
151 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
152 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
153 * @param useCapture - Whether or not events of these types will be dispatched to the registered listener before being dispatched to any target beneath it in the DOM tree.
154 *
155 * @returns The provided listener when successfully attached; otherwise, `undefined`.
156 *
157 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
158 */
159declare function on(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): EventListenerOrEventListenerObject | null | undefined;
160/**
161 * Attach an event listener that will be called whenever a specified event type is delivered to the given node from specific descendants.
162 *
163 * @param node - The node on which the event listener is attached.
164 * @param selector - A selector string to filter the descendants of the given node that trigger the event.
165 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
166 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
167 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters|options object} specifying characteristics about the event listener.
168 *
169 * @returns The provided listener when successfully attached; otherwise, `undefined`.
170 *
171 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
172 */
173declare function on(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, options: AddEventListenerOptions): EventListenerOrEventListenerObject | null | undefined;
174/**
175 * Attach an event listener that will be called once whenever each of the specified event types are delivered to the given target.
176 *
177 * @param target - The target on which the event listener is attached.
178 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
179 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
180 * @param useCapture - Whether or not events of these types will be dispatched to the registered listener before being dispatched to any target beneath it in the DOM tree.
181 *
182 * @returns The provided listener when successfully attached; otherwise, `undefined`.
183 *
184 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
185 */
186declare function one(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): EventListenerOrEventListenerObject | null | undefined;
187/**
188 * Attach an event listener that will be called once whenever each of the specified event types are delivered to the given target.
189 *
190 * @param target - The target on which the event listener is attached.
191 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
192 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
193 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters|options object} specifying characteristics about the event listener.
194 *
195 * @returns The provided listener when successfully attached; otherwise, `undefined`.
196 *
197 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
198 */
199declare function one(target: EventTarget, types: string, listener: EventListenerOrEventListenerObject | null, options: AddEventListenerOptions): EventListenerOrEventListenerObject | null | undefined;
200/**
201 * Attach an event listener that will be called once whenever each of the specified event types are delivered to the given node from specific descendants.
202 *
203 * @param node - The node on which the event listener is attached.
204 * @param selector - A selector string to filter the descendants of the given node that trigger the event.
205 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
206 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
207 * @param useCapture - Whether or not events of these types will be dispatched to the registered listener before being dispatched to any target beneath it in the DOM tree.
208 *
209 * @returns The provided listener when successfully attached; otherwise, `undefined`.
210 *
211 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
212 */
213declare function one(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, useCapture?: boolean): EventListenerOrEventListenerObject | null | undefined;
214/**
215 * Attach an event listener that will be called once whenever each of the specified event types are delivered to the given node from specific descendants.
216 *
217 * @param node - The node on which the event listener is attached.
218 * @param selector - A selector string to filter the descendants of the given node that trigger the event.
219 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to listen for.
220 * @param listener - The object that receives a notification (an object that implements the {@link https://developer.mozilla.org/en-US/docs/Web/API/Event|Event} interface) when an event of a specified type occurs. This must be an object implementing the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventListener|EventListener} interface, or a function.
221 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters|options object} specifying characteristics about the event listener.
222 *
223 * @returns The provided listener when successfully attached; otherwise, `undefined`.
224 *
225 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback} The event listener callback for details on the callback itself.
226 */
227declare function one(node: Node, selector: string, types: string, listener: EventListenerOrEventListenerObject | null, options: AddEventListenerOptions): EventListenerOrEventListenerObject | null | undefined;
228/**
229 * Executes all listeners attached to the given target for the specified event types.
230 *
231 * @param target - The target on which the specified events are executed.
232 * @param types - A case-sensitive string representing the {@link https://developer.mozilla.org/en-US/docs/Web/Events|event type}s to execute.
233 * @param options - An {@link https://developer.mozilla.org/en-US/docs/Web/API/Event/Event#values|options object} specifying characteristics about the triggered event.
234 *
235 * @returns A list of tuples, where the first value is the event type and the second is `true`; unless the event is cancelable and at least one of the event listeners which received the event called {@link https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault|`Event.preventDefault()`}, the second value is `false`.
236 */
237declare function trigger(target: EventTarget, types: string, options?: EventInit): Array<[
238 string,
239 boolean
240]>;
241export { any, off, on, one, trigger };