Skip to content

Commit 1916afc

Browse files
authored
Merge pull request #523 from crispthinking/composed-path
Introduce composedPath for Events
2 parents bbf761b + cf68da3 commit 1916afc

11 files changed

+2600
-1083
lines changed

baselines/dom.generated.d.ts

+1,055-400
Large diffs are not rendered by default.

baselines/dom.iterable.generated.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ interface DOMStringList {
3131

3232
interface DOMTokenList {
3333
[Symbol.iterator](): IterableIterator<string>;
34+
entries(): IterableIterator<[number, string]>;
35+
keys(): IterableIterator<number>;
36+
values(): IterableIterator<string>;
3437
}
3538

3639
interface DataTransferItemList {

baselines/webworker.generated.d.ts

+104-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ interface CloseEventInit extends EventInit {
3333
wasClean?: boolean;
3434
}
3535

36+
interface CustomEventInit<T = any> extends EventInit {
37+
detail?: T;
38+
}
39+
3640
interface DOMMatrix2DInit {
3741
a?: number;
3842
b?: number;
@@ -275,11 +279,32 @@ interface EventListener {
275279
(evt: Event): void;
276280
}
277281

282+
interface AbortController {
283+
/**
284+
* Returns the AbortSignal object associated with this object.
285+
*/
286+
readonly signal: AbortSignal;
287+
/**
288+
* Invoking this method will set this object's AbortSignal's aborted flag and
289+
* signal to any observers that the associated activity is to be aborted.
290+
*/
291+
abort(): void;
292+
}
293+
294+
declare var AbortController: {
295+
prototype: AbortController;
296+
new(): AbortController;
297+
};
298+
278299
interface AbortSignalEventMap {
279300
"abort": ProgressEvent;
280301
}
281302

282303
interface AbortSignal extends EventTarget {
304+
/**
305+
* Returns true if this AbortSignal's AbortController has signaled to abort, and false
306+
* otherwise.
307+
*/
283308
readonly aborted: boolean;
284309
onabort: ((this: AbortSignal, ev: ProgressEvent) => any) | null;
285310
addEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
@@ -530,6 +555,20 @@ declare var CryptoKey: {
530555
new(): CryptoKey;
531556
};
532557

558+
interface CustomEvent<T = any> extends Event {
559+
/**
560+
* Returns any custom data event was created with.
561+
* Typically used for synthetic events.
562+
*/
563+
readonly detail: T;
564+
initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void;
565+
}
566+
567+
declare var CustomEvent: {
568+
prototype: CustomEvent;
569+
new<T>(typeArg: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
570+
};
571+
533572
interface DOMException {
534573
readonly code: number;
535574
readonly message: string;
@@ -835,22 +874,56 @@ declare var ErrorEvent: {
835874
};
836875

837876
interface Event {
877+
/**
878+
* Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
879+
*/
838880
readonly bubbles: boolean;
839881
cancelBubble: boolean;
840882
readonly cancelable: boolean;
883+
/**
884+
* Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
885+
*/
841886
readonly composed: boolean;
887+
/**
888+
* Returns the object whose event listener's callback is currently being
889+
* invoked.
890+
*/
842891
readonly currentTarget: EventTarget | null;
843892
readonly defaultPrevented: boolean;
844893
readonly eventPhase: number;
894+
/**
895+
* Returns true if event was dispatched by the user agent, and
896+
* false otherwise.
897+
*/
845898
readonly isTrusted: boolean;
846899
returnValue: boolean;
900+
/**
901+
* Returns the object to which event is dispatched (its target).
902+
*/
847903
readonly target: EventTarget | null;
904+
/**
905+
* Returns the event's timestamp as the number of milliseconds measured relative to
906+
* the time origin.
907+
*/
848908
readonly timeStamp: number;
909+
/**
910+
* Returns the type of event, e.g.
911+
* "click", "hashchange", or
912+
* "submit".
913+
*/
849914
readonly type: string;
850-
deepPath(): EventTarget[];
915+
composedPath(): EventTarget[];
851916
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
852917
preventDefault(): void;
918+
/**
919+
* Invoking this method prevents event from reaching
920+
* any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any
921+
* other objects.
922+
*/
853923
stopImmediatePropagation(): void;
924+
/**
925+
* When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
926+
*/
854927
stopPropagation(): void;
855928
readonly AT_TARGET: number;
856929
readonly BUBBLING_PHASE: number;
@@ -860,7 +933,7 @@ interface Event {
860933

861934
declare var Event: {
862935
prototype: Event;
863-
new(typeArg: string, eventInitDict?: EventInit): Event;
936+
new(type: string, eventInitDict?: EventInit): Event;
864937
readonly AT_TARGET: number;
865938
readonly BUBBLING_PHASE: number;
866939
readonly CAPTURING_PHASE: number;
@@ -894,9 +967,26 @@ interface EventSourceInit {
894967
}
895968

896969
interface EventTarget {
970+
/**
971+
* Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
972+
* The options argument sets listener-specific options. For compatibility this can be a
973+
* boolean, in which case the method behaves exactly as if the value was specified as options's capture.
974+
* When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
975+
* When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in §2.8 Observing event listeners.
976+
* When set to true, options's once indicates that the callback will only be invoked once after which the event listener will
977+
* be removed.
978+
* The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
979+
*/
897980
addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
898-
dispatchEvent(evt: Event): boolean;
899-
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
981+
/**
982+
* Dispatches a synthetic event event to target and returns true
983+
* if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
984+
*/
985+
dispatchEvent(event: Event): boolean;
986+
/**
987+
* Removes the event listener in target's event listener list with the same type, callback, and options.
988+
*/
989+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
900990
}
901991

902992
declare var EventTarget: {
@@ -2658,15 +2748,23 @@ interface PerformanceObserverCallback {
26582748
declare var onmessage: ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) | null;
26592749
declare function close(): void;
26602750
declare function postMessage(message: any, transfer?: any[]): void;
2661-
declare function dispatchEvent(evt: Event): boolean;
2751+
/**
2752+
* Dispatches a synthetic event event to target and returns true
2753+
* if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
2754+
*/
2755+
declare function dispatchEvent(event: Event): boolean;
26622756
declare var caches: CacheStorage;
26632757
declare var isSecureContext: boolean;
26642758
declare var location: WorkerLocation;
26652759
declare var onerror: ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any) | null;
26662760
declare var performance: Performance;
26672761
declare var self: WorkerGlobalScope;
26682762
declare function msWriteProfilerMark(profilerMarkName: string): void;
2669-
declare function dispatchEvent(evt: Event): boolean;
2763+
/**
2764+
* Dispatches a synthetic event event to target and returns true
2765+
* if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
2766+
*/
2767+
declare function dispatchEvent(event: Event): boolean;
26702768
declare var indexedDB: IDBFactory;
26712769
declare var msIndexedDB: IDBFactory;
26722770
declare var navigator: WorkerNavigator;

inputfiles/addedTypes.json

+120-22
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,122 @@
11
{
22
"mixins": {
33
"mixin": {
4+
"DocumentAndElementEventHandlers": {
5+
"events": {
6+
"event": [
7+
{
8+
"name": "copy",
9+
"type": "ClipboardEvent"
10+
},
11+
{
12+
"name": "cut",
13+
"type": "ClipboardEvent"
14+
},
15+
{
16+
"name": "paste",
17+
"type": "ClipboardEvent"
18+
}
19+
]
20+
}
21+
},
422
"GlobalEventHandlers": {
523
"events": {
624
"event": [
725
{
826
"name": "cancel",
927
"type": "Event"
28+
},
29+
{
30+
"name": "drag",
31+
"type": "DragEvent"
32+
},
33+
{
34+
"name": "dragend",
35+
"type": "DragEvent"
36+
},
37+
{
38+
"name": "dragenter",
39+
"type": "DragEvent"
40+
},
41+
{
42+
"name": "dragleave",
43+
"type": "DragEvent"
44+
},
45+
{
46+
"name": "dragover",
47+
"type": "DragEvent"
48+
},
49+
{
50+
"name": "dragstart",
51+
"type": "DragEvent"
52+
},
53+
{
54+
"name": "drop",
55+
"type": "DragEvent"
56+
},
57+
{
58+
"name": "keydown",
59+
"type": "KeyboardEvent"
60+
},
61+
{
62+
"name": "keypress",
63+
"type": "KeyboardEvent"
64+
},
65+
{
66+
"name": "keyup",
67+
"type": "KeyboardEvent"
68+
},
69+
{
70+
"name": "mousedown",
71+
"type": "MouseEvent"
72+
},
73+
{
74+
"name": "mouseenter",
75+
"type": "MouseEvent"
76+
},
77+
{
78+
"name": "mouseleave",
79+
"type": "MouseEvent"
80+
},
81+
{
82+
"name": "mousemove",
83+
"type": "MouseEvent"
84+
},
85+
{
86+
"name": "mouseout",
87+
"type": "MouseEvent"
88+
},
89+
{
90+
"name": "mouseover",
91+
"type": "MouseEvent"
92+
},
93+
{
94+
"name": "mouseup",
95+
"type": "MouseEvent"
96+
},
97+
{
98+
"name": "scroll",
99+
"type": "UIEvent"
100+
},
101+
{
102+
"name": "select",
103+
"type": "UIEvent"
104+
},
105+
{
106+
"name": "wheel",
107+
"type": "WheelEvent"
108+
},
109+
{
110+
"name": "securitypolicyviolation",
111+
"type": "SecurityPolicyViolationEvent"
112+
},
113+
{
114+
"name": "dblclick",
115+
"type": "MouseEvent"
116+
},
117+
{
118+
"name": "contextmenu",
119+
"type": "MouseEvent"
10120
}
11121
]
12122
}
@@ -73,6 +183,16 @@
73183
},
74184
"interfaces": {
75185
"interface": {
186+
"AbortSignal": {
187+
"events": {
188+
"event": [
189+
{
190+
"name": "abort",
191+
"type": "ProgressEvent"
192+
}
193+
]
194+
}
195+
},
76196
"ApplicationCache": {
77197
"events": {
78198
"event": [
@@ -1114,28 +1234,6 @@
11141234
}
11151235
}
11161236
},
1117-
"Event": {
1118-
"name": "Event",
1119-
"properties": {
1120-
"property": {
1121-
"composed": {
1122-
"name": "composed",
1123-
"read-only": 1,
1124-
"override-type": "boolean"
1125-
}
1126-
}
1127-
},
1128-
"methods": {
1129-
"method": {
1130-
"deepPath": {
1131-
"name": "deepPath",
1132-
"override-signatures": [
1133-
"deepPath(): EventTarget[]"
1134-
]
1135-
}
1136-
}
1137-
}
1138-
},
11391237
"ElementCreationOptions": {
11401238
"name": "ElementCreationOptions",
11411239
"exposed": "Window",

0 commit comments

Comments
 (0)