Skip to content

Fix lib breaks #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 44 additions & 40 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -4364,68 +4365,68 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par
getElementsByTagName<K extends keyof SVGElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>;
getElementsByTagName(qualifiedName: string): HTMLCollectionOf<Element>;
/**
* 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<HTMLElement>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf<Element>;
/**
* 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<T extends Node>(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<HTMLElement>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf<Element>;
importNode<T extends Node>(importedNode: T, deep: boolean): T;
/** @deprecated */
releaseEvents(): void;
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand Down Expand Up @@ -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).
*/
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -9282,7 +9284,7 @@ interface Location {
/**
* Reloads the current page.
*/
reload(): void;
reload(forcedReload?: boolean): void;
Copy link
Contributor

@saschanaz saschanaz Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change it to two overloads and mark it as deprecated.

/**
* Removes the current page from the session history and navigates to the given URL.
*/
Expand Down Expand Up @@ -10256,6 +10258,7 @@ interface Node extends EventTarget {
* Returns the last child.
*/
readonly lastChild: ChildNode | null;
readonly namespaceURI: string | null;
/**
* Returns the next sibling.
*/
Expand Down Expand Up @@ -10293,7 +10296,7 @@ interface Node extends EventTarget {
/**
* Returns the parent element.
*/
readonly parentElement: Element | null;
readonly parentElement: HTMLElement | null;
/**
* Returns the parent.
*/
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down
4 changes: 4 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2570,6 +2570,10 @@
"new-type": "RTCTransport",
"override-type": "RTCDtlsTransport | RTCSrtpSdesTransport"
},
{
"new-type": "MouseWheelEvent",
"type": "WheelEvent"
},
{
"new-type": "WindowProxy",
"type": "Window"
Expand Down
3 changes: 2 additions & 1 deletion inputfiles/knownTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"RsaOaepParams",
"RsaPssParams",
"Transferable",
"VideoFacingModeEnum"
"VideoFacingModeEnum",
"MouseWheelEvent"
],
"Worker": [
"AesCbcParams",
Expand Down
53 changes: 49 additions & 4 deletions inputfiles/overridingTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@
"type": "TransitionEvent"
}
]
},
"properties": {
"property": {
"onerror": {
"override-type": "ErrorEventHandler"
}
}
}
},
"RandomSource": {
Expand Down Expand Up @@ -413,6 +420,17 @@
"override-signatures": [
"getElementsByName(elementName: string): NodeListOf<HTMLElement>"
]
},
"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"
]
}
}
},
Expand Down Expand Up @@ -459,7 +477,10 @@
},
"location": {
"read-only": 0
}
},
"body": {
"nullable": false
}
}
}
},
Expand Down Expand Up @@ -506,7 +527,7 @@
"override-type": "Node & ParentNode | null"
},
"parentElement": {
"override-type": "Element | null"
"override-type": "HTMLElement | null"
},
"childNodes": {
"override-type": "NodeListOf<ChildNode>"
Expand All @@ -516,6 +537,11 @@
},
"lastChild": {
"override-type": "ChildNode | null"
},
"namespaceURI": {
"name":"namespaceURI",
"read-only": 1,
"override-type": "string | null"
}
}
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -2313,6 +2347,17 @@
"[index: number]: Element",
"[name: string]: any"
]
},
"Location": {
"methods": {
"method": {
"reload": {
"override-signatures": [
"reload(forcedReload?: boolean): void"
]
}
}
}
}
}
},
Expand Down Expand Up @@ -2497,4 +2542,4 @@
"typedefs": {
"typedef": []
}
}
}
7 changes: 0 additions & 7 deletions inputfiles/removedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@
}
}
},
"Event": {
"properties": {
"property": {
"srcElement": null
}
}
},
"FileReaderProgressEvent": null,
"HTMLAreasCollection": null,
"HTMLBodyElement": {
Expand Down
3 changes: 2 additions & 1 deletion src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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) ||
Expand Down