Skip to content

Commit 6062c8e

Browse files
committed
Fix EventTarget.addEventListener and EventTarget.removeEventListener
1 parent 077bd91 commit 6062c8e

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

baselines/dom.generated.d.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -3701,9 +3701,9 @@ declare var Event: {
37013701
}
37023702

37033703
interface EventTarget {
3704-
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
3704+
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | AddEventListenerOptions): void;
37053705
dispatchEvent(evt: Event): boolean;
3706-
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
3706+
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | EventListenerOptions): void;
37073707
}
37083708

37093709
declare var EventTarget: {
@@ -14178,6 +14178,15 @@ interface PromiseRejectionEventInit extends EventInit {
1417814178
reason?: any;
1417914179
}
1418014180

14181+
interface EventListenerOptions {
14182+
capture: boolean;
14183+
}
14184+
14185+
interface AddEventListenerOptions extends EventListenerOptions {
14186+
passive: boolean;
14187+
once: boolean;
14188+
}
14189+
1418114190
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
1418214191

1418314192
interface ErrorEventHandler {
@@ -14877,7 +14886,7 @@ declare function scrollTo(options?: ScrollToOptions): void;
1487714886
declare function scrollBy(options?: ScrollToOptions): void;
1487814887
declare function toString(): string;
1487914888
declare function dispatchEvent(evt: Event): boolean;
14880-
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
14889+
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | EventListenerOptions): void;
1488114890
declare function clearInterval(handle: number): void;
1488214891
declare function clearTimeout(handle: number): void;
1488314892
declare function setInterval(handler: (...args: any[]) => void, timeout: number): number;

baselines/webworker.generated.d.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ declare var Event: {
403403
}
404404

405405
interface EventTarget {
406-
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
406+
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | AddEventListenerOptions): void;
407407
dispatchEvent(evt: Event): boolean;
408-
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
408+
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | EventListenerOptions): void;
409409
}
410410

411411
declare var EventTarget: {
@@ -1740,6 +1740,15 @@ interface JsonWebKey {
17401740
k?: string;
17411741
}
17421742

1743+
interface EventListenerOptions {
1744+
capture: boolean;
1745+
}
1746+
1747+
interface AddEventListenerOptions extends EventListenerOptions {
1748+
passive: boolean;
1749+
once: boolean;
1750+
}
1751+
17431752
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
17441753

17451754
interface ErrorEventHandler {
@@ -1779,7 +1788,7 @@ declare function msWriteProfilerMark(profilerMarkName: string): void;
17791788
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
17801789
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
17811790
declare function dispatchEvent(evt: Event): boolean;
1782-
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
1791+
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | EventListenerOptions): void;
17831792
declare var indexedDB: IDBFactory;
17841793
declare var msIndexedDB: IDBFactory;
17851794
declare var navigator: WorkerNavigator;
@@ -1798,7 +1807,7 @@ declare function btoa(rawString: string): string;
17981807
declare var console: Console;
17991808
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
18001809
declare function dispatchEvent(evt: Event): boolean;
1801-
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
1810+
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | EventListenerOptions): void;
18021811
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
18031812
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
18041813
type AlgorithmIdentifier = string | Algorithm;

inputfiles/addedTypes.json

+20
Original file line numberDiff line numberDiff line change
@@ -1580,5 +1580,25 @@
15801580
"name": "set",
15811581
"flavor": "Web",
15821582
"signatures": ["set(name: string, value: string | Blob, fileName?: string): void"]
1583+
},
1584+
{
1585+
"kind": "interface",
1586+
"name": "EventListenerOptions",
1587+
"properties": [{
1588+
"name": "capture",
1589+
"type": "boolean"
1590+
}]
1591+
},
1592+
{
1593+
"kind": "interface",
1594+
"name": "AddEventListenerOptions",
1595+
"extends": "EventListenerOptions",
1596+
"properties": [{
1597+
"name": "passive",
1598+
"type": "boolean"
1599+
}, {
1600+
"name": "once",
1601+
"type": "boolean"
1602+
}]
15831603
}
15841604
]

inputfiles/overridingTypes.json

+12
Original file line numberDiff line numberDiff line change
@@ -1047,5 +1047,17 @@
10471047
"name": "append",
10481048
"flavor": "Web",
10491049
"signatures": ["append(name: string, value: string | Blob, fileName?: string): void"]
1050+
},
1051+
{
1052+
"kind": "method",
1053+
"interface": "EventTarget",
1054+
"name": "addEventListener",
1055+
"signatures": ["addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | AddEventListenerOptions): void"]
1056+
},
1057+
{
1058+
"kind": "method",
1059+
"interface": "EventTarget",
1060+
"name": "removeEventListener",
1061+
"signatures": ["removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean | EventListenerOptions): void"]
10501062
}
10511063
]

0 commit comments

Comments
 (0)