diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index c25f9ccab..e10fd981a 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -3799,7 +3799,7 @@ interface DhKeyGenParams extends Algorithm { prime: Uint8Array; } -interface DocumentEventMap extends GlobalEventHandlersEventMap { +interface DocumentEventMap extends GlobalEventHandlersEventMap, DocumentAndElementEventHandlersEventMap { "abort": UIEvent; "activate": Event; "beforeactivate": Event; @@ -3891,7 +3891,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "webkitfullscreenerror": Event; } -interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent { +interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent, DocumentAndElementEventHandlers { /** * Sets or gets the URL for the current document. */ @@ -3903,7 +3903,7 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent /** * Gets the object that has the focus when the parent document has focus. */ - readonly activeElement: Element; + readonly activeElement: Element | null; /** * Sets or gets the color of all active links in the document. */ @@ -3932,7 +3932,7 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent /** * Specifies the beginning and end of the document body. */ - body: HTMLElement; + body: HTMLElement | null; readonly characterSet: string; /** * Gets or sets the character set used to encode the object. @@ -3942,9 +3942,28 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent * Gets a value that indicates whether standards-compliant mode is switched on for the object. */ readonly compatMode: string; + /** + * Returns the HTTP cookies that apply to the Document. If there are no cookies or + * cookies can't be applied to this resource, the empty string will be returned. + * Can be set, to add a new cookie to the element's set of HTTP cookies. + * If the contents are sandboxed into a + * unique origin (e.g. in an iframe with the sandbox attribute), a + * "SecurityError" DOMException will be thrown on getting + * and setting. + */ cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement | null; - readonly defaultView: Window; + /** + * Returns the script element, or the SVG script element, + * that is currently executing, as long as the element represents a classic script. + * In the case of reentrant script execution, returns the one that most recently started executing + * amongst those that have not yet finished executing. + * Returns null if the Document is not currently executing a script + * or SVG script element (e.g., because the running script is an event + * handler, or a timeout), or if the currently executing script or SVG + * script element represents a module script. + */ + readonly currentScript: HTMLOrSVGScriptElement | null; + readonly defaultView: WindowProxy | null; /** * Sets or gets a value that indicates whether the document can be edited. */ @@ -3980,7 +3999,10 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent readonly forms: HTMLCollectionOf; readonly fullscreenElement: Element | null; readonly fullscreenEnabled: boolean; - readonly head: HTMLHeadElement; + /** + * Returns the head element. + */ + readonly head: HTMLHeadElement | null; readonly hidden: boolean; /** * Retrieves a collection, in source order, of img objects in the document. @@ -4010,7 +4032,7 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent /** * Contains information about the current URL. */ - location: Location; + location: Location | null; msCSSOMElementFloatMetrics: boolean; msCapsLockWarningOff: boolean; /** @@ -4088,6 +4110,9 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent onvisibilitychange: ((this: Document, ev: Event) => any) | null; onwebkitfullscreenchange: ((this: Document, ev: Event) => any) | null; onwebkitfullscreenerror: ((this: Document, ev: Event) => any) | null; + /** + * Return an HTMLCollection of the embed elements in the Document. + */ readonly plugins: HTMLCollectionOf; readonly pointerLockElement: Element; /** @@ -4276,7 +4301,7 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent * @param showUI Display the user interface, defaults to false. * @param value Value to assign. */ - execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + execCommand(commandId: string, showUI?: boolean, value?: string): boolean; /** * Displays help information for the given command identifier. * @param commandId Displays help information for the given command identifier. @@ -4369,12 +4394,12 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent * Writes one or more HTML expressions to a document in the specified window. * @param content Specifies the text and HTML tags to write. */ - write(...content: string[]): void; + write(...text: string[]): void; /** * 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. */ - writeln(...content: string[]): void; + writeln(...text: string[]): 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; @@ -4713,6 +4738,12 @@ interface ElementCSSInlineStyle { readonly style: CSSStyleDeclaration; } +interface ElementContentEditable { + contentEditable: string; + inputMode: string; + readonly isContentEditable: boolean; +} + interface ElementCreationOptions { is?: string; } @@ -5438,12 +5469,7 @@ declare var HTMLBaseFontElement: { }; interface HTMLBodyElementEventMap extends HTMLElementEventMap, WindowEventHandlersEventMap { - "blur": FocusEvent; - "error": ErrorEvent; - "focus": FocusEvent; - "load": Event; "orientationchange": Event; - "scroll": UIEvent; } interface HTMLBodyElement extends HTMLElement, WindowEventHandlers { @@ -5728,111 +5754,26 @@ declare var HTMLDocument: { }; interface HTMLElementEventMap extends ElementEventMap, GlobalEventHandlersEventMap, DocumentAndElementEventHandlersEventMap { - "abort": UIEvent; - "activate": Event; - "beforeactivate": Event; - "beforecopy": Event; - "beforecut": Event; - "beforedeactivate": Event; - "beforepaste": Event; - "blur": FocusEvent; - "canplay": Event; - "canplaythrough": Event; - "change": Event; - "click": MouseEvent; - "contextmenu": PointerEvent; - "copy": ClipboardEvent; - "cuechange": Event; - "cut": ClipboardEvent; - "dblclick": MouseEvent; - "deactivate": Event; - "drag": DragEvent; - "dragend": DragEvent; - "dragenter": DragEvent; - "dragleave": DragEvent; - "dragover": DragEvent; - "dragstart": DragEvent; - "drop": DragEvent; - "durationchange": Event; - "emptied": Event; - "ended": Event; - "error": ErrorEvent; - "focus": FocusEvent; - "input": Event; - "invalid": Event; - "keydown": KeyboardEvent; - "keypress": KeyboardEvent; - "keyup": KeyboardEvent; - "load": Event; - "loadeddata": Event; - "loadedmetadata": Event; - "loadstart": Event; - "mousedown": MouseEvent; - "mouseenter": MouseEvent; - "mouseleave": MouseEvent; - "mousemove": MouseEvent; - "mouseout": MouseEvent; - "mouseover": MouseEvent; - "mouseup": MouseEvent; - "mousewheel": WheelEvent; - "MSContentZoom": Event; - "MSManipulationStateChanged": Event; - "paste": ClipboardEvent; - "pause": Event; - "play": Event; - "playing": Event; - "progress": ProgressEvent; - "ratechange": Event; - "reset": Event; - "scroll": UIEvent; - "seeked": Event; - "seeking": Event; - "select": UIEvent; - "selectstart": Event; - "stalled": Event; - "submit": Event; - "suspend": Event; - "timeupdate": Event; - "volumechange": Event; - "waiting": Event; } -interface HTMLElement extends Element, ElementCSSInlineStyle, GlobalEventHandlers, DocumentAndElementEventHandlers, HTMLOrSVGElement { +interface HTMLElement extends Element, GlobalEventHandlers, DocumentAndElementEventHandlers, ElementContentEditable, HTMLOrSVGElement { accessKey: string; - contentEditable: string; - readonly dataset: DOMStringMap; + readonly accessKeyLabel: string; + autocapitalize: string; dir: string; draggable: boolean; hidden: boolean; - hideFocus: boolean; innerText: string; - readonly isContentEditable: boolean; lang: string; readonly offsetHeight: number; readonly offsetLeft: number; readonly offsetParent: Element | null; readonly offsetTop: number; readonly offsetWidth: number; - onactivate: ((this: HTMLElement, ev: Event) => any) | null; - onbeforeactivate: ((this: HTMLElement, ev: Event) => any) | null; - onbeforecopy: ((this: HTMLElement, ev: Event) => any) | null; - onbeforecut: ((this: HTMLElement, ev: Event) => any) | null; - onbeforedeactivate: ((this: HTMLElement, ev: Event) => any) | null; - onbeforepaste: ((this: HTMLElement, ev: Event) => any) | null; - ondeactivate: ((this: HTMLElement, ev: Event) => any) | null; - onmousewheel: ((this: HTMLElement, ev: WheelEvent) => any) | null; - onmscontentzoom: ((this: HTMLElement, ev: Event) => any) | null; - onmsmanipulationstatechanged: ((this: HTMLElement, ev: Event) => any) | null; - onselectstart: ((this: HTMLElement, ev: Event) => any) | null; - outerText: string; spellcheck: boolean; - tabIndex: number; title: string; - blur(): void; + translate: boolean; click(): void; - dragDrop(): boolean; - focus(options?: FocusOptions): void; - msGetInputContext(): MSInputMethodContext; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -6112,6 +6053,9 @@ declare var HTMLFrameElement: { new(): HTMLFrameElement; }; +interface HTMLFrameSetElementEventMap extends HTMLElementEventMap, WindowEventHandlersEventMap { +} + interface HTMLFrameSetElement extends HTMLElement, WindowEventHandlers { /** * Sets or retrieves the frame widths of the object. @@ -6123,11 +6067,9 @@ interface HTMLFrameSetElement extends HTMLElement, WindowEventHandlers { */ /** @deprecated */ rows: string; - addEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: WindowEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLFrameSetElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: WindowEventHandlersEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLFrameSetElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } @@ -6227,10 +6169,6 @@ interface HTMLHyperlinkElementUtils { username: string; } -interface HTMLIFrameElementEventMap extends HTMLElementEventMap { - "load": Event; -} - interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { /** * Sets or retrieves how the object is aligned with adjacent text. @@ -6293,9 +6231,9 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: K, listener: (this: HTMLIFrameElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: K, listener: (this: HTMLIFrameElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } @@ -10718,7 +10656,7 @@ declare var ProgressEvent: { }; interface PromiseRejectionEvent extends Event { - readonly promise: PromiseLike; + readonly promise: Promise; readonly reason: any; } @@ -16380,7 +16318,6 @@ interface WritableStreamErrorCallback { interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "abbr": HTMLElement; - "acronym": HTMLElement; "address": HTMLElement; "applet": HTMLAppletElement; "area": HTMLAreaElement; @@ -16391,14 +16328,12 @@ interface HTMLElementTagNameMap { "base": HTMLBaseElement; "basefont": HTMLBaseFontElement; "bdo": HTMLElement; - "big": HTMLElement; "blockquote": HTMLQuoteElement; "body": HTMLBodyElement; "br": HTMLBRElement; "button": HTMLButtonElement; "canvas": HTMLCanvasElement; "caption": HTMLTableCaptionElement; - "center": HTMLElement; "cite": HTMLElement; "code": HTMLElement; "col": HTMLTableColElement; @@ -16439,9 +16374,7 @@ interface HTMLElementTagNameMap { "img": HTMLImageElement; "input": HTMLInputElement; "ins": HTMLModElement; - "isindex": HTMLUnknownElement; "kbd": HTMLElement; - "keygen": HTMLElement; "label": HTMLLabelElement; "legend": HTMLLegendElement; "li": HTMLLIElement; @@ -16453,9 +16386,6 @@ interface HTMLElementTagNameMap { "meta": HTMLMetaElement; "meter": HTMLMeterElement; "nav": HTMLElement; - "nextid": HTMLUnknownElement; - "nobr": HTMLElement; - "noframes": HTMLElement; "noscript": HTMLElement; "object": HTMLObjectElement; "ol": HTMLOListElement; @@ -16465,7 +16395,6 @@ interface HTMLElementTagNameMap { "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; - "plaintext": HTMLElement; "pre": HTMLPreElement; "progress": HTMLProgressElement; "q": HTMLQuoteElement; @@ -16480,7 +16409,6 @@ interface HTMLElementTagNameMap { "small": HTMLElement; "source": HTMLSourceElement; "span": HTMLSpanElement; - "strike": HTMLElement; "strong": HTMLElement; "style": HTMLStyleElement; "sub": HTMLElement; @@ -16497,7 +16425,6 @@ interface HTMLElementTagNameMap { "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; - "tt": HTMLElement; "u": HTMLElement; "ul": HTMLUListElement; "var": HTMLElement; @@ -16834,6 +16761,7 @@ type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | type HTMLOrSVGImageElement = HTMLImageElement | SVGImageElement; type CanvasImageSource = HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap; type MessageEventSource = WindowProxy | MessagePort | ServiceWorker; +type HTMLOrSVGScriptElement = HTMLScriptElement | SVGScriptElement; type ImageBitmapSource = CanvasImageSource | Blob | ImageData; type OnErrorEventHandler = OnErrorEventHandlerNonNull | null; type OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull | null; diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index 307aa732f..cdabc847f 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -1888,7 +1888,7 @@ declare var ProgressEvent: { }; interface PromiseRejectionEvent extends Event { - readonly promise: PromiseLike; + readonly promise: Promise; readonly reason: any; } diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index ad2493bed..8e6592cb5 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -22,43 +22,6 @@ } } }, - "HTMLOrSVGElement": { - "name": "HTMLOrSVGElement", - "properties": { - "property": { - "nonce": { - "name": "nonce", - "type": "DOMString" - }, - "tabIndex": { - "name": "tabIndex", - "type": "long" - }, - "dataset": { - "name": "dataset", - "read-only": 1, - "type": "DOMStringMap" - } - } - }, - "methods": { - "method": { - "blur": { - "name": "blur", - "override-signatures": [ - "blur(): void" - ] - }, - "focus": { - "name": "focus", - "override-signatures": [ - "focus(options?: FocusOptions): void" - ] - } - } - }, - "no-interface-object": "1" - }, "ParentNode": { "name": "ParentNode", "exposed": "Window", @@ -1077,7 +1040,10 @@ "no-interface-object": "1" }, "SVGElement": { - "implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"] + "implements": [ + "GlobalEventHandlers", + "DocumentAndElementEventHandlers" + ] }, "Text": { "name": "Text", @@ -1127,30 +1093,6 @@ }, "no-interface-object": "1" }, - "PromiseRejectionEvent": { - "name": "PromiseRejectionEvent", - "extends": "Event", - "exposed": "Window Worker", - "constructor": { - "override-signatures": [ - "new(type: string, eventInitDict: PromiseRejectionEventInit): PromiseRejectionEvent" - ] - }, - "properties": { - "property": { - "promise": { - "name": "promise", - "read-only": 1, - "override-type": "PromiseLike" - }, - "reason": { - "name": "reason", - "read-only": 1, - "override-type": "any" - } - } - } - }, "HTMLMainElement": { "name": "HTMLMainElement", "extends": "HTMLElement", @@ -1820,9 +1762,6 @@ }, "no-interface-object": "1" }, - "HTMLElement": { - "implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"] - }, "HTMLAnchorElement": { "element": [ { @@ -1886,6 +1825,112 @@ } ] }, + "HTMLElement": { + "element": [ + { + "name": "abbr" + }, + { + "name": "address" + }, + { + "name": "article" + }, + { + "name": "aside" + }, + { + "name": "b" + }, + { + "name": "bdo" + }, + { + "name": "cite" + }, + { + "name": "code" + }, + { + "name": "dd" + }, + { + "name": "dfn" + }, + { + "name": "dt" + }, + { + "name": "em" + }, + { + "name": "figcaption" + }, + { + "name": "figure" + }, + { + "name": "footer" + }, + { + "name": "header" + }, + { + "name": "hgroup" + }, + { + "name": "i" + }, + { + "name": "kbd" + }, + { + "name": "mark" + }, + { + "name": "nav" + }, + { + "name": "noscript" + }, + { + "name": "rt" + }, + { + "name": "ruby" + }, + { + "name": "s" + }, + { + "name": "samp" + }, + { + "name": "section" + }, + { + "name": "small" + }, + { + "name": "strong" + }, + { + "name": "sub" + }, + { + "name": "sup" + }, + { + "name": "u" + }, + { + "name": "var" + }, + { + "name": "wbr" + } + ] + }, "HTMLFormElement": { "element": [ { @@ -2279,23 +2324,6 @@ } } } - }, - "PromiseRejectionEventInit": { - "name": "PromiseRejectionEventInit", - "extends": "EventInit", - "members": { - "member": { - "promise": { - "name": "promise", - "override-type": "Promise", - "required": 1 - }, - "reason": { - "name": "reason", - "override-type": "any" - } - } - } } } }, diff --git a/inputfiles/comments.json b/inputfiles/comments.json index 14a292a90..e3cc2b2b0 100644 --- a/inputfiles/comments.json +++ b/inputfiles/comments.json @@ -1069,9 +1069,6 @@ }, "longDesc": { "comment": "/**\r\n * Sets or retrieves a URI to a long description of the object.\r\n */" - }, - "onload": { - "comment": "/**\r\n * Raised when the object has been completely received from the server.\r\n */" } } } diff --git a/inputfiles/idl/HTML - DOM.commentmap.json b/inputfiles/idl/HTML - DOM.commentmap.json new file mode 100644 index 000000000..98a3708f8 --- /dev/null +++ b/inputfiles/idl/HTML - DOM.commentmap.json @@ -0,0 +1,19 @@ +{ + "document-referrer": "Returns the URL of the Document\nfrom which the user navigated to this one, unless it was blocked or there was no such document,\nin which case it returns the empty string.\nThe noreferrer link type can be used to block the\nreferrer.", + "document-cookie": "Returns the HTTP cookies that apply to the Document. If there are no cookies or\ncookies can't be applied to this resource, the empty string will be returned.\nCan be set, to add a new cookie to the element's set of HTTP cookies.\nIf the contents are sandboxed into a\nunique origin (e.g. in an iframe with the sandbox attribute), a\n\"SecurityError\" DOMException will be thrown on getting\nand setting.", + "document-lastmodified": "Returns the date of the last modification to the document, as reported by the server, in the\nform \"MM/DD/YYYY hh:mm:ss\", in the user's local time zone.\nIf the last modification date is not known, the current time is returned instead.", + "document-readystate": "Returns \"loading\" while the Document is loading, \"interactive\" once it is finished parsing but still loading subresources, and\n\"complete\" once it has loaded.\nThe readystatechange event fires on the\nDocument object when this value changes.\nThe DOMContentLoaded event fires after the transition to\n\"interactive\" but before the transition to \"complete\", at the point where all subresources apart from async script elements have loaded.", + "document-head": "Returns the head element.", + "document-body": "Returns the body element.\nCan be set, to replace the body element.\nIf the new value is not a body or frameset element, this will throw\na \"HierarchyRequestError\" DOMException.", + "document-images": "Returns an HTMLCollection of the img elements in the Document.", + "document-plugins": "Return an HTMLCollection of the embed elements in the Document.", + "document-links": "Returns an HTMLCollection of the a and area elements\nin the Document that have href\nattributes.", + "document-forms": "Return an HTMLCollection of the form elements in the Document.", + "document-scripts": "Return an HTMLCollection of the script elements in the Document.", + "document-getelementsbyname": "Returns a NodeList of elements in the Document that have a name attribute with the value name.", + "document-currentscript": "Returns the script element, or the SVG script element,\nthat is currently executing, as long as the element represents a classic script.\nIn the case of reentrant script execution, returns the one that most recently started executing\namongst those that have not yet finished executing.\nReturns null if the Document is not currently executing a script\nor SVG script element (e.g., because the running script is an event\nhandler, or a timeout), or if the currently executing script or SVG\nscript element represents a module script.", + "dir": "Returns the html element's dir attribute's value, if any.\nCan be set, to either \"ltr\", \"rtl\", or \"auto\" to replace the html element's dir attribute's value.\nIf there is no html element, returns the empty string and ignores new values.", + "style": "Returns a CSSStyleDeclaration object for the element's style attribute.", + "dataset": "Returns a DOMStringMap object for the element's data-* attributes.\nHyphenated names become camel-cased. For example, data-foo-bar=\"\"\nbecomes element.dataset.fooBar.", + "innertext": "Returns the element's text content \"as rendered\".\nCan be set, to replace the element's children with the given value, but with line breaks\nconverted to br elements." +} diff --git a/inputfiles/idl/HTML - DOM.widl b/inputfiles/idl/HTML - DOM.widl new file mode 100644 index 000000000..86fbbb9c2 --- /dev/null +++ b/inputfiles/idl/HTML - DOM.widl @@ -0,0 +1,99 @@ +enum DocumentReadyState { "loading", "interactive", "complete" }; +typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement; + +[OverrideBuiltins] +partial interface Document { + // resource metadata management + [PutForwards=href, Unforgeable] readonly attribute Location? location; + attribute USVString domain; + readonly attribute USVString referrer; + attribute USVString cookie; + readonly attribute DOMString lastModified; + readonly attribute DocumentReadyState readyState; + + // DOM tree accessors + getter object (DOMString name); + [CEReactions] attribute DOMString title; + [CEReactions] attribute DOMString dir; + [CEReactions] attribute HTMLElement? body; + readonly attribute HTMLHeadElement? head; + [SameObject] readonly attribute HTMLCollection images; + [SameObject] readonly attribute HTMLCollection embeds; + [SameObject] readonly attribute HTMLCollection plugins; + [SameObject] readonly attribute HTMLCollection links; + [SameObject] readonly attribute HTMLCollection forms; + [SameObject] readonly attribute HTMLCollection scripts; + NodeList getElementsByName(DOMString elementName); + readonly attribute HTMLOrSVGScriptElement? currentScript; // classic scripts in a document tree only + + // dynamic markup insertion + [CEReactions] Document open(optional DOMString type, optional DOMString replace = ""); // type is ignored + WindowProxy open(USVString url, DOMString name, DOMString features); + [CEReactions] void close(); + [CEReactions] void write(DOMString... text); + [CEReactions] void writeln(DOMString... text); + + // user interaction + readonly attribute WindowProxy? defaultView; + readonly attribute Element? activeElement; + boolean hasFocus(); + [CEReactions] attribute DOMString designMode; + [CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = ""); + boolean queryCommandEnabled(DOMString commandId); + boolean queryCommandIndeterm(DOMString commandId); + boolean queryCommandState(DOMString commandId); + boolean queryCommandSupported(DOMString commandId); + DOMString queryCommandValue(DOMString commandId); + + // special event handler IDL attributes that only apply to Document objects + [LenientThis] attribute EventHandler onreadystatechange; +}; +Document includes GlobalEventHandlers; +Document includes DocumentAndElementEventHandlers; + +[Exposed=Window, + HTMLConstructor] +interface HTMLElement : Element { + // metadata attributes + [CEReactions] attribute DOMString title; + [CEReactions] attribute DOMString lang; + [CEReactions] attribute boolean translate; + [CEReactions] attribute DOMString dir; + + // user interaction + [CEReactions] attribute boolean hidden; + void click(); + [CEReactions] attribute DOMString accessKey; + readonly attribute DOMString accessKeyLabel; + [CEReactions] attribute boolean draggable; + [CEReactions] attribute boolean spellcheck; + [CEReactions] attribute DOMString autocapitalize; + + [CEReactions] attribute [TreatNullAs=EmptyString] DOMString innerText; +}; + +HTMLElement includes GlobalEventHandlers; +HTMLElement includes DocumentAndElementEventHandlers; +HTMLElement includes ElementContentEditable; +HTMLElement includes HTMLOrSVGElement; + +// Note: intentionally not [HTMLConstructor] +[Exposed=Window] +interface HTMLUnknownElement : HTMLElement { }; + +interface mixin HTMLOrSVGElement { + [SameObject] readonly attribute DOMStringMap dataset; + attribute DOMString nonce; + + [CEReactions] attribute long tabIndex; + void focus(optional FocusOptions options); + void blur(); +}; + +[Exposed=Window, + OverrideBuiltins] +interface DOMStringMap { + getter DOMString (DOMString name); + [CEReactions] setter void (DOMString name, DOMString value); + [CEReactions] deleter void (DOMString name); +}; diff --git a/inputfiles/idlSources.json b/inputfiles/idlSources.json index ad4f81787..ddf7f4100 100644 --- a/inputfiles/idlSources.json +++ b/inputfiles/idlSources.json @@ -56,6 +56,10 @@ "url": "https://html.spec.whatwg.org/multipage/custom-elements.html", "title": "HTML - Custom elements" }, + { + "url": "https://html.spec.whatwg.org/multipage/dom.html", + "title": "HTML - DOM" + }, { "url": "https://html.spec.whatwg.org/multipage/dnd.html", "title": "HTML - Drag and drop" diff --git a/inputfiles/knownTypes.json b/inputfiles/knownTypes.json index 307d69b39..727c7790a 100644 --- a/inputfiles/knownTypes.json +++ b/inputfiles/knownTypes.json @@ -42,7 +42,6 @@ "Keyframe", "MutationRecordType", "Pbkdf2Params", - "PromiseRejectionEventInit", "PropertyIndexedKeyframes", "RTCAnswerOptions", "RTCCertificateExpiration", @@ -78,13 +77,11 @@ "RsaKeyGenParams", "RsaOaepParams", "RsaPssParams", - "VideoFacingModeEnum", - "WindowOrWorkerGlobalScope" + "VideoFacingModeEnum" ], "Worker": [ "ClientTypes", "IDBArrayKey", - "IDBValidKey", - "PromiseRejectionEventInit" + "IDBValidKey" ] } diff --git a/inputfiles/overridingTypes.json b/inputfiles/overridingTypes.json index fcf7b2e20..70e9589e1 100644 --- a/inputfiles/overridingTypes.json +++ b/inputfiles/overridingTypes.json @@ -143,19 +143,6 @@ "callback-interfaces": { "interface": {} }, - "enums": { - "enum": { - "DocumentReadyState": { - "specs": "dom4", - "value": [ - "loading", - "interactive", - "complete" - ], - "name": "DocumentReadyState" - } - } - }, "interfaces": { "interface": { "MediaQueryList": { @@ -348,19 +335,10 @@ }, "properties": { "property": { - "readyState": { - "name": "readyState", - "override-type": "DocumentReadyState" - }, "documentElement": { "name": "documentElement", "override-type": "HTMLElement" }, - "currentScript": { - "name": "currentScript", - "read-only": 1, - "override-type": "HTMLScriptElement | SVGScriptElement | null" - }, "anchors": { "name": "anchors", "override-type": "HTMLCollectionOf" @@ -820,19 +798,6 @@ } } }, - "HTMLElement": { - "implements": ["HTMLOrSVGElement"], - "methods": { - "method": { - "focus": { - "name": "focus", - "override-signatures": [ - "focus(options?: FocusOptions): void" - ] - } - } - } - }, "SVGElement": { "name": "SVGElement", "properties": { diff --git a/inputfiles/removedTypes.json b/inputfiles/removedTypes.json index f917d8703..8f8d45fd2 100644 --- a/inputfiles/removedTypes.json +++ b/inputfiles/removedTypes.json @@ -61,7 +61,12 @@ "HTMLBodyElement": { "properties": { "property": { - "onresize": null + "onblur": null, + "onerror": null, + "onfocus": null, + "onload": null, + "onresize": null, + "onscroll": null } } }, @@ -85,6 +90,13 @@ "HTMLHRElement": { "implements": null }, + "HTMLIFrameElement": { + "properties": { + "property": { + "onload": null + } + } + }, "MediaQueryListListener": null, "MessageEvent": { "methods": { diff --git a/src/emitter.ts b/src/emitter.ts index 9082416b9..797171d69 100644 --- a/src/emitter.ts +++ b/src/emitter.ts @@ -187,7 +187,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { } else if (e.deprecated) { htmlDeprecatedResult[e.name] = i.name; - } + } else { htmlResult[e.name] = i.name; } @@ -210,12 +210,21 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { function getParentsWithEventHandler(i: Browser.Interface) { function getParentEventHandler(i: Browser.Interface): Browser.Interface[] { - return iNameToEhList[i.name] && iNameToEhList[i.name].length ? [i] : getParentsWithEventHandler(i); + const hasEventListener = iNameToEhList[i.name] && iNameToEhList[i.name].length; + if (hasEventListener) { + return [i]; + } + const ehParents = getParentsWithEventHandler(i); + if (ehParents.length > 1) { + return [i]; + } + return ehParents; } const extendedParentWithEventHandler = allInterfacesMap[i.extends] && getParentEventHandler(allInterfacesMap[i.extends]) || []; const implementedParentsWithEventHandler = i.implements ? flatMap(i.implements, i => getParentEventHandler(allInterfacesMap[i])) : []; - return extendedParentWithEventHandler.concat(implementedParentsWithEventHandler); + + return distinct(extendedParentWithEventHandler.concat(implementedParentsWithEventHandler)); } function getEventTypeInInterface(eName: string, i: Browser.Interface) { @@ -702,14 +711,15 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { } function tryEmitTypedEventHandlerForInterface(addOrRemove: string, optionsType: string) { - if (iNameToEhList[i.name] && iNameToEhList[i.name].length) { + const hasEventListener = iNameToEhList[i.name] && iNameToEhList[i.name].length; + const ehParentCount = iNameToEhParents[i.name] && iNameToEhParents[i.name].length; + + if (hasEventListener || ehParentCount > 1) { emitTypedEventHandler(fPrefix, addOrRemove, i, optionsType); return true; } - if (iNameToEhParents[i.name] && iNameToEhParents[i.name].length) { - iNameToEhParents[i.name] - .sort(compareName) - .forEach(i => emitTypedEventHandler(fPrefix, addOrRemove, i, optionsType)); + else if (ehParentCount === 1) { + emitTypedEventHandler(fPrefix, addOrRemove, iNameToEhParents[i.name][0], optionsType); return true; } return false; @@ -846,9 +856,12 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { printer.printLine(`"${eHandler.eventName}": ${getEventTypeInInterface(eHandler.eventName, i)};`); } - if (iNameToEhList[i.name] && iNameToEhList[i.name].length) { + const hasEventHandlers = iNameToEhList[i.name] && iNameToEhList[i.name].length; + const ehParentCount = iNameToEhParents[i.name] && iNameToEhParents[i.name].length; + + if (hasEventHandlers || ehParentCount > 1) { printer.printLine(`interface ${i.name}EventMap`); - if (iNameToEhParents[i.name] && iNameToEhParents[i.name].length) { + if (ehParentCount) { const extend = iNameToEhParents[i.name].map(i => i.name + "EventMap"); printer.print(` extends ${extend.join(", ")}`); } @@ -1074,7 +1087,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { const iterableGetter = findIterableGetter(); const lengthProperty = findLengthProperty(i) || findLengthProperty(allInterfacesMap[i.extends]); if (iterableGetter && lengthProperty) { - return [convertDomTypeToTsType({ + return [convertDomTypeToTsType({ type: iterableGetter.signature[0].type, "override-type": iterableGetter.signature[0]["override-type"] })]; @@ -1115,7 +1128,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) { if (comments && comments[m.name]) { printer.printLine(comments[m.name]); } - printer.printLine(`${ m.name }(): ${ m.definition };`); + printer.printLine(`${m.name}(): ${m.definition};`); }); } diff --git a/src/helpers.ts b/src/helpers.ts index d7c11a077..ed55143e7 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -208,7 +208,7 @@ export function resolveExposure(obj: any, exposure: string, override?: boolean) obj.exposed = exposure; } for (const key in obj) { - if (typeof obj[key] === "object") { + if (typeof obj[key] === "object" && obj[key]) { resolveExposure(obj[key], exposure, override); } }