diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 16ed8a257..d912d196e 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -3930,7 +3930,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par /** * Specifies the beginning and end of the document body. */ - body: HTMLElement | null; + body: HTMLElement; /** * Returns document's encoding. */ @@ -4096,6 +4096,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par /** @deprecated */ captureEvents(): void; caretPositionFromPoint(x: number, y: number): CaretPosition | null; + caretRangeFromPoint(x: number, y: number): Range; /** @deprecated */ clear(): void; /** @@ -4320,7 +4321,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par * @param filter A custom NodeFilter function to use. * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. */ - createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker; + createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null, entityReferenceExpansion?: boolean): TreeWalker; /** * Returns the element for the specified x coordinate and the specified y coordinate. * @param x The x-offset @@ -4364,68 +4365,68 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par getElementsByTagName(qualifiedName: K): HTMLCollectionOf; getElementsByTagName(qualifiedName: string): HTMLCollectionOf; /** - * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. - * @param commandId String that specifies a command identifier. - */ - queryCommandIndeterm(commandId: string): boolean; - /** - * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + * If namespace and localName are + * "*" returns a HTMLCollection of all descendant elements. + * If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName. + * If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace. + * Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName. */ + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; /** - * Returns a Boolean value that indicates whether the current command is supported on the current range. - * @param commandId Specifies a command identifier. + * Gets a value indicating whether the object currently has focus. */ - queryCommandSupported(commandId: string): boolean; + hasFocus(): boolean; + importNode(importedNode: T, deep: boolean): T; /** - * Returns the current value of the document, range, or current selection for the given command. - * @param commandId String that specifies a command identifier. + * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. + * @param url Specifies a MIME type for the document. + * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. + * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. + * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - queryCommandValue(commandId: string): string; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. */ queryCommandEnabled(commandId: string): boolean; /** - * Gets a value indicating whether the object currently has focus. + * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. + * @param commandId String that specifies a command identifier. */ - hasFocus(): boolean; + queryCommandIndeterm(commandId: string): boolean; /** * Returns a Boolean value that indicates the current state of the command. * @param commandId String that specifies a command identifier. */ queryCommandState(commandId: string): boolean; /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. - * @param content The text and HTML tags to write. + * Returns a Boolean value that indicates whether the current command is supported on the current range. + * @param commandId Specifies a command identifier. */ - writeln(...text: string[]): void; + queryCommandSupported(commandId: string): boolean; + /** + * Returns the current value of the document, range, or current selection for the given command. + * @param commandId String that specifies a command identifier. + */ + queryCommandValue(commandId: string): string; + /** @deprecated */ + releaseEvents(): void; /** * Writes one or more HTML expressions to a document in the specified window. * @param content Specifies the text and HTML tags to write. */ write(...text: string[]): void; /** - * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. - * @param url Specifies a MIME type for the document. - * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. - * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. - * @param replace Specifies whether the existing entry for the document is replaced in the history list. + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * @param content The text and HTML tags to write. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document; + writeln(...text: string[]): void; /** - * If namespace and localName are - * "*" returns a HTMLCollection of all descendant elements. - * If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName. - * If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace. - * Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName. + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ - getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; - getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; - getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; - importNode(importedNode: T, deep: boolean): T; - /** @deprecated */ - releaseEvents(): void; addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -4846,6 +4847,7 @@ interface Event { */ readonly isTrusted: boolean; returnValue: boolean; + readonly srcElement: Element | null; /** * Returns the object to which event is dispatched (its target). */ @@ -5335,7 +5337,7 @@ interface GlobalEventHandlers { * Fires when an error occurs during object loading. * @param ev The event. */ - onerror: ((this: GlobalEventHandlers, ev: ErrorEvent) => any) | null; + onerror: ErrorEventHandler; /** * Fires when the object receives focus. * @param ev The event. @@ -9282,7 +9284,7 @@ interface Location { /** * Reloads the current page. */ - reload(): void; + reload(forcedReload?: boolean): void; /** * Removes the current page from the session history and navigates to the given URL. */ @@ -10256,6 +10258,7 @@ interface Node extends EventTarget { * Returns the last child. */ readonly lastChild: ChildNode | null; + readonly namespaceURI: string | null; /** * Returns the next sibling. */ @@ -10293,7 +10296,7 @@ interface Node extends EventTarget { /** * Returns the parent element. */ - readonly parentElement: Element | null; + readonly parentElement: HTMLElement | null; /** * Returns the parent. */ @@ -17365,7 +17368,7 @@ declare var onended: ((this: Window, ev: Event) => any) | null; * Fires when an error occurs during object loading. * @param ev The event. */ -declare var onerror: ((this: Window, ev: ErrorEvent) => any) | null; +declare var onerror: ErrorEventHandler; /** * Fires when the object receives focus. * @param ev The event. @@ -17623,6 +17626,7 @@ type IDBKeyPath = string; type Transferable = ArrayBuffer | MessagePort | ImageBitmap; type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type MouseWheelEvent = WheelEvent; type WindowProxy = Window; type AlignSetting = "start" | "center" | "end" | "left" | "right"; type AnimationPlayState = "idle" | "running" | "paused" | "finished"; diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index 2fb41d298..9c9dcaba1 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -1019,6 +1019,7 @@ interface Event { */ readonly isTrusted: boolean; returnValue: boolean; + readonly srcElement: object | null; /** * Returns the object to which event is dispatched (its target). */ diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index a23b8179e..3d97c2ac6 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -2570,6 +2570,10 @@ "new-type": "RTCTransport", "override-type": "RTCDtlsTransport | RTCSrtpSdesTransport" }, + { + "new-type": "MouseWheelEvent", + "type": "WheelEvent" + }, { "new-type": "WindowProxy", "type": "Window" diff --git a/inputfiles/knownTypes.json b/inputfiles/knownTypes.json index 66c1f4290..0bfd9ee67 100644 --- a/inputfiles/knownTypes.json +++ b/inputfiles/knownTypes.json @@ -79,7 +79,8 @@ "RsaOaepParams", "RsaPssParams", "Transferable", - "VideoFacingModeEnum" + "VideoFacingModeEnum", + "MouseWheelEvent" ], "Worker": [ "AesCbcParams", diff --git a/inputfiles/overridingTypes.json b/inputfiles/overridingTypes.json index 7f65b9da0..8cab7416f 100644 --- a/inputfiles/overridingTypes.json +++ b/inputfiles/overridingTypes.json @@ -124,6 +124,13 @@ "type": "TransitionEvent" } ] + }, + "properties": { + "property": { + "onerror": { + "override-type": "ErrorEventHandler" + } + } } }, "RandomSource": { @@ -413,6 +420,17 @@ "override-signatures": [ "getElementsByName(elementName: string): NodeListOf" ] + }, + "createTreeWalker": { + "override-signatures": [ + "createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null, entityReferenceExpansion?: boolean): TreeWalker" + ] + }, + "caretRangeFromPoint": { + "name": "caretRangeFromPoint", + "override-signatures" :[ + "caretRangeFromPoint(x: number, y: number): Range" + ] } } }, @@ -459,7 +477,10 @@ }, "location": { "read-only": 0 - } + }, + "body": { + "nullable": false + } } } }, @@ -506,7 +527,7 @@ "override-type": "Node & ParentNode | null" }, "parentElement": { - "override-type": "Element | null" + "override-type": "HTMLElement | null" }, "childNodes": { "override-type": "NodeListOf" @@ -516,6 +537,11 @@ }, "lastChild": { "override-type": "ChildNode | null" + }, + "namespaceURI": { + "name":"namespaceURI", + "read-only": 1, + "override-type": "string | null" } } } @@ -2155,7 +2181,15 @@ }, "Event": { "name": "Event", - "override-exposed": "Window Worker" + "override-exposed": "Window Worker", + "properties": { + "property": { + "srcElement": { + "type": "Element", + "nullable": 1 + } + } + } }, "ReadableStream": { "name": "ReadableStream", @@ -2313,6 +2347,17 @@ "[index: number]: Element", "[name: string]: any" ] + }, + "Location": { + "methods": { + "method": { + "reload": { + "override-signatures": [ + "reload(forcedReload?: boolean): void" + ] + } + } + } } } }, @@ -2497,4 +2542,4 @@ "typedefs": { "typedef": [] } -} +} \ No newline at end of file diff --git a/inputfiles/removedTypes.json b/inputfiles/removedTypes.json index d0a87a568..b6c1f3712 100644 --- a/inputfiles/removedTypes.json +++ b/inputfiles/removedTypes.json @@ -49,13 +49,6 @@ } } }, - "Event": { - "properties": { - "property": { - "srcElement": null - } - } - }, "FileReaderProgressEvent": null, "HTMLAreasCollection": null, "HTMLBodyElement": { diff --git a/src/emitter.ts b/src/emitter.ts index 8b93fc4d6..334515576 100644 --- a/src/emitter.ts +++ b/src/emitter.ts @@ -168,7 +168,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { const eventType = eType === "Event" || dependsOn(eType, "Event") ? eType : defaultEventType; return { name: p.name, eventName, eventType }; })); - + const iNameToConstList = arrayToMap(allInterfaces, i => i.name, i => !i.constants ? [] : mapToArray(i.constants.constant)); @@ -328,6 +328,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { case "EventListener": return "EventListenerOrEventListenerObject"; } if (flavor === Flavor.Web && objDomType === "Client") return "object"; + if (flavor === Flavor.Worker && objDomType === "Element") return "object"; // Name of an interface / enum / dict. Just return itself if (allInterfacesMap[objDomType] || allLegacyWindowAliases.includes(objDomType) ||