Skip to content

Commit

Permalink
Fix EventTarget.addEventListener and EventTarget.removeEventListener (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Diullei authored and zhengbli committed Mar 30, 2017
1 parent 8053340 commit 537df01
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
15 changes: 12 additions & 3 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3701,9 +3701,9 @@ declare var Event: {
}

interface EventTarget {
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
dispatchEvent(evt: Event): boolean;
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}

declare var EventTarget: {
Expand Down Expand Up @@ -14178,6 +14178,15 @@ interface PromiseRejectionEventInit extends EventInit {
reason?: any;
}

interface EventListenerOptions {
capture?: boolean;
}

interface AddEventListenerOptions extends EventListenerOptions {
passive?: boolean;
once?: boolean;
}

declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;

interface ErrorEventHandler {
Expand Down Expand Up @@ -14877,7 +14886,7 @@ declare function scrollTo(options?: ScrollToOptions): void;
declare function scrollBy(options?: ScrollToOptions): void;
declare function toString(): string;
declare function dispatchEvent(evt: Event): boolean;
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
declare function clearInterval(handle: number): void;
declare function clearTimeout(handle: number): void;
declare function setInterval(handler: (...args: any[]) => void, timeout: number): number;
Expand Down
17 changes: 13 additions & 4 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ declare var Event: {
}

interface EventTarget {
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
dispatchEvent(evt: Event): boolean;
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}

declare var EventTarget: {
Expand Down Expand Up @@ -1740,6 +1740,15 @@ interface JsonWebKey {
k?: string;
}

interface EventListenerOptions {
capture?: boolean;
}

interface AddEventListenerOptions extends EventListenerOptions {
passive?: boolean;
once?: boolean;
}

declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;

interface ErrorEventHandler {
Expand Down Expand Up @@ -1779,7 +1788,7 @@ declare function msWriteProfilerMark(profilerMarkName: string): void;
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function dispatchEvent(evt: Event): boolean;
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
declare var indexedDB: IDBFactory;
declare var msIndexedDB: IDBFactory;
declare var navigator: WorkerNavigator;
Expand All @@ -1798,7 +1807,7 @@ declare function btoa(rawString: string): string;
declare var console: Console;
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
declare function dispatchEvent(evt: Event): boolean;
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
type AlgorithmIdentifier = string | Algorithm;
Expand Down
20 changes: 20 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1580,5 +1580,25 @@
"name": "set",
"flavor": "Web",
"signatures": ["set(name: string, value: string | Blob, fileName?: string): void"]
},
{
"kind": "interface",
"name": "EventListenerOptions",
"properties": [{
"name": "capture?",
"type": "boolean"
}]
},
{
"kind": "interface",
"name": "AddEventListenerOptions",
"extends": "EventListenerOptions",
"properties": [{
"name": "passive?",
"type": "boolean"
}, {
"name": "once?",
"type": "boolean"
}]
}
]
12 changes: 12 additions & 0 deletions inputfiles/overridingTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1047,5 +1047,17 @@
"name": "append",
"flavor": "Web",
"signatures": ["append(name: string, value: string | Blob, fileName?: string): void"]
},
{
"kind": "method",
"interface": "EventTarget",
"name": "addEventListener",
"signatures": ["addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void"]
},
{
"kind": "method",
"interface": "EventTarget",
"name": "removeEventListener",
"signatures": ["removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void"]
}
]

0 comments on commit 537df01

Please sign in to comment.