Skip to content

Add HTML DOM types #525

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 4 commits into from
Jul 9, 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
182 changes: 55 additions & 127 deletions baselines/dom.generated.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ declare var ProgressEvent: {
};

interface PromiseRejectionEvent extends Event {
readonly promise: PromiseLike<any>;
readonly promise: Promise<any>;
readonly reason: any;
}

Expand Down
192 changes: 110 additions & 82 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1077,7 +1040,10 @@
"no-interface-object": "1"
},
"SVGElement": {
"implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"]
"implements": [
"GlobalEventHandlers",
"DocumentAndElementEventHandlers"
]
},
"Text": {
"name": "Text",
Expand Down Expand Up @@ -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<any>"
},
"reason": {
"name": "reason",
"read-only": 1,
"override-type": "any"
}
}
}
},
"HTMLMainElement": {
"name": "HTMLMainElement",
"extends": "HTMLElement",
Expand Down Expand Up @@ -1820,9 +1762,6 @@
},
"no-interface-object": "1"
},
"HTMLElement": {
"implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"]
},
"HTMLAnchorElement": {
"element": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -2279,23 +2324,6 @@
}
}
}
},
"PromiseRejectionEventInit": {
"name": "PromiseRejectionEventInit",
"extends": "EventInit",
"members": {
"member": {
"promise": {
"name": "promise",
"override-type": "Promise<any>",
"required": 1
},
"reason": {
"name": "reason",
"override-type": "any"
}
}
}
}
}
},
Expand Down
3 changes: 0 additions & 3 deletions inputfiles/comments.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 */"
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions inputfiles/idl/HTML - DOM.commentmap.json
Original file line number Diff line number Diff line change
@@ -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."
}
99 changes: 99 additions & 0 deletions inputfiles/idl/HTML - DOM.widl
Original file line number Diff line number Diff line change
@@ -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);
};
4 changes: 4 additions & 0 deletions inputfiles/idlSources.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading