Skip to content

Commit e4bdc45

Browse files
authored
Merge pull request #525 from saschanaz/html-dom
Add HTML DOM types
2 parents 4ad375d + 544e304 commit e4bdc45

12 files changed

+329
-267
lines changed

baselines/dom.generated.d.ts

Lines changed: 55 additions & 127 deletions
Large diffs are not rendered by default.

baselines/webworker.generated.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,7 @@ declare var ProgressEvent: {
18881888
};
18891889

18901890
interface PromiseRejectionEvent extends Event {
1891-
readonly promise: PromiseLike<any>;
1891+
readonly promise: Promise<any>;
18921892
readonly reason: any;
18931893
}
18941894

inputfiles/addedTypes.json

Lines changed: 110 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,6 @@
2222
}
2323
}
2424
},
25-
"HTMLOrSVGElement": {
26-
"name": "HTMLOrSVGElement",
27-
"properties": {
28-
"property": {
29-
"nonce": {
30-
"name": "nonce",
31-
"type": "DOMString"
32-
},
33-
"tabIndex": {
34-
"name": "tabIndex",
35-
"type": "long"
36-
},
37-
"dataset": {
38-
"name": "dataset",
39-
"read-only": 1,
40-
"type": "DOMStringMap"
41-
}
42-
}
43-
},
44-
"methods": {
45-
"method": {
46-
"blur": {
47-
"name": "blur",
48-
"override-signatures": [
49-
"blur(): void"
50-
]
51-
},
52-
"focus": {
53-
"name": "focus",
54-
"override-signatures": [
55-
"focus(options?: FocusOptions): void"
56-
]
57-
}
58-
}
59-
},
60-
"no-interface-object": "1"
61-
},
6225
"ParentNode": {
6326
"name": "ParentNode",
6427
"exposed": "Window",
@@ -1133,7 +1096,10 @@
11331096
}
11341097
},
11351098
"SVGElement": {
1136-
"implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"]
1099+
"implements": [
1100+
"GlobalEventHandlers",
1101+
"DocumentAndElementEventHandlers"
1102+
]
11371103
},
11381104
"Text": {
11391105
"name": "Text",
@@ -1183,30 +1149,6 @@
11831149
},
11841150
"no-interface-object": "1"
11851151
},
1186-
"PromiseRejectionEvent": {
1187-
"name": "PromiseRejectionEvent",
1188-
"extends": "Event",
1189-
"exposed": "Window Worker",
1190-
"constructor": {
1191-
"override-signatures": [
1192-
"new(type: string, eventInitDict: PromiseRejectionEventInit): PromiseRejectionEvent"
1193-
]
1194-
},
1195-
"properties": {
1196-
"property": {
1197-
"promise": {
1198-
"name": "promise",
1199-
"read-only": 1,
1200-
"override-type": "PromiseLike<any>"
1201-
},
1202-
"reason": {
1203-
"name": "reason",
1204-
"read-only": 1,
1205-
"override-type": "any"
1206-
}
1207-
}
1208-
}
1209-
},
12101152
"HTMLMainElement": {
12111153
"name": "HTMLMainElement",
12121154
"extends": "HTMLElement",
@@ -1876,9 +1818,6 @@
18761818
},
18771819
"no-interface-object": "1"
18781820
},
1879-
"HTMLElement": {
1880-
"implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"]
1881-
},
18821821
"HTMLAnchorElement": {
18831822
"element": [
18841823
{
@@ -1942,6 +1881,112 @@
19421881
}
19431882
]
19441883
},
1884+
"HTMLElement": {
1885+
"element": [
1886+
{
1887+
"name": "abbr"
1888+
},
1889+
{
1890+
"name": "address"
1891+
},
1892+
{
1893+
"name": "article"
1894+
},
1895+
{
1896+
"name": "aside"
1897+
},
1898+
{
1899+
"name": "b"
1900+
},
1901+
{
1902+
"name": "bdo"
1903+
},
1904+
{
1905+
"name": "cite"
1906+
},
1907+
{
1908+
"name": "code"
1909+
},
1910+
{
1911+
"name": "dd"
1912+
},
1913+
{
1914+
"name": "dfn"
1915+
},
1916+
{
1917+
"name": "dt"
1918+
},
1919+
{
1920+
"name": "em"
1921+
},
1922+
{
1923+
"name": "figcaption"
1924+
},
1925+
{
1926+
"name": "figure"
1927+
},
1928+
{
1929+
"name": "footer"
1930+
},
1931+
{
1932+
"name": "header"
1933+
},
1934+
{
1935+
"name": "hgroup"
1936+
},
1937+
{
1938+
"name": "i"
1939+
},
1940+
{
1941+
"name": "kbd"
1942+
},
1943+
{
1944+
"name": "mark"
1945+
},
1946+
{
1947+
"name": "nav"
1948+
},
1949+
{
1950+
"name": "noscript"
1951+
},
1952+
{
1953+
"name": "rt"
1954+
},
1955+
{
1956+
"name": "ruby"
1957+
},
1958+
{
1959+
"name": "s"
1960+
},
1961+
{
1962+
"name": "samp"
1963+
},
1964+
{
1965+
"name": "section"
1966+
},
1967+
{
1968+
"name": "small"
1969+
},
1970+
{
1971+
"name": "strong"
1972+
},
1973+
{
1974+
"name": "sub"
1975+
},
1976+
{
1977+
"name": "sup"
1978+
},
1979+
{
1980+
"name": "u"
1981+
},
1982+
{
1983+
"name": "var"
1984+
},
1985+
{
1986+
"name": "wbr"
1987+
}
1988+
]
1989+
},
19451990
"HTMLFormElement": {
19461991
"element": [
19471992
{
@@ -2335,23 +2380,6 @@
23352380
}
23362381
}
23372382
}
2338-
},
2339-
"PromiseRejectionEventInit": {
2340-
"name": "PromiseRejectionEventInit",
2341-
"extends": "EventInit",
2342-
"members": {
2343-
"member": {
2344-
"promise": {
2345-
"name": "promise",
2346-
"override-type": "Promise<any>",
2347-
"required": 1
2348-
},
2349-
"reason": {
2350-
"name": "reason",
2351-
"override-type": "any"
2352-
}
2353-
}
2354-
}
23552383
}
23562384
}
23572385
},

inputfiles/comments.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,9 +1069,6 @@
10691069
},
10701070
"longDesc": {
10711071
"comment": "/**\r\n * Sets or retrieves a URI to a long description of the object.\r\n */"
1072-
},
1073-
"onload": {
1074-
"comment": "/**\r\n * Raised when the object has been completely received from the server.\r\n */"
10751072
}
10761073
}
10771074
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"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.",
3+
"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.",
4+
"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.",
5+
"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.",
6+
"document-head": "Returns the head element.",
7+
"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.",
8+
"document-images": "Returns an HTMLCollection of the img elements in the Document.",
9+
"document-plugins": "Return an HTMLCollection of the embed elements in the Document.",
10+
"document-links": "Returns an HTMLCollection of the a and area elements\nin the Document that have href\nattributes.",
11+
"document-forms": "Return an HTMLCollection of the form elements in the Document.",
12+
"document-scripts": "Return an HTMLCollection of the script elements in the Document.",
13+
"document-getelementsbyname": "Returns a NodeList of elements in the Document that have a name attribute with the value name.",
14+
"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.",
15+
"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.",
16+
"style": "Returns a CSSStyleDeclaration object for the element's style attribute.",
17+
"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.",
18+
"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."
19+
}

inputfiles/idl/HTML - DOM.widl

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
enum DocumentReadyState { "loading", "interactive", "complete" };
2+
typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
3+
4+
[OverrideBuiltins]
5+
partial interface Document {
6+
// resource metadata management
7+
[PutForwards=href, Unforgeable] readonly attribute Location? location;
8+
attribute USVString domain;
9+
readonly attribute USVString referrer;
10+
attribute USVString cookie;
11+
readonly attribute DOMString lastModified;
12+
readonly attribute DocumentReadyState readyState;
13+
14+
// DOM tree accessors
15+
getter object (DOMString name);
16+
[CEReactions] attribute DOMString title;
17+
[CEReactions] attribute DOMString dir;
18+
[CEReactions] attribute HTMLElement? body;
19+
readonly attribute HTMLHeadElement? head;
20+
[SameObject] readonly attribute HTMLCollection images;
21+
[SameObject] readonly attribute HTMLCollection embeds;
22+
[SameObject] readonly attribute HTMLCollection plugins;
23+
[SameObject] readonly attribute HTMLCollection links;
24+
[SameObject] readonly attribute HTMLCollection forms;
25+
[SameObject] readonly attribute HTMLCollection scripts;
26+
NodeList getElementsByName(DOMString elementName);
27+
readonly attribute HTMLOrSVGScriptElement? currentScript; // classic scripts in a document tree only
28+
29+
// dynamic markup insertion
30+
[CEReactions] Document open(optional DOMString type, optional DOMString replace = ""); // type is ignored
31+
WindowProxy open(USVString url, DOMString name, DOMString features);
32+
[CEReactions] void close();
33+
[CEReactions] void write(DOMString... text);
34+
[CEReactions] void writeln(DOMString... text);
35+
36+
// user interaction
37+
readonly attribute WindowProxy? defaultView;
38+
readonly attribute Element? activeElement;
39+
boolean hasFocus();
40+
[CEReactions] attribute DOMString designMode;
41+
[CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
42+
boolean queryCommandEnabled(DOMString commandId);
43+
boolean queryCommandIndeterm(DOMString commandId);
44+
boolean queryCommandState(DOMString commandId);
45+
boolean queryCommandSupported(DOMString commandId);
46+
DOMString queryCommandValue(DOMString commandId);
47+
48+
// special event handler IDL attributes that only apply to Document objects
49+
[LenientThis] attribute EventHandler onreadystatechange;
50+
};
51+
Document includes GlobalEventHandlers;
52+
Document includes DocumentAndElementEventHandlers;
53+
54+
[Exposed=Window,
55+
HTMLConstructor]
56+
interface HTMLElement : Element {
57+
// metadata attributes
58+
[CEReactions] attribute DOMString title;
59+
[CEReactions] attribute DOMString lang;
60+
[CEReactions] attribute boolean translate;
61+
[CEReactions] attribute DOMString dir;
62+
63+
// user interaction
64+
[CEReactions] attribute boolean hidden;
65+
void click();
66+
[CEReactions] attribute DOMString accessKey;
67+
readonly attribute DOMString accessKeyLabel;
68+
[CEReactions] attribute boolean draggable;
69+
[CEReactions] attribute boolean spellcheck;
70+
[CEReactions] attribute DOMString autocapitalize;
71+
72+
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString innerText;
73+
};
74+
75+
HTMLElement includes GlobalEventHandlers;
76+
HTMLElement includes DocumentAndElementEventHandlers;
77+
HTMLElement includes ElementContentEditable;
78+
HTMLElement includes HTMLOrSVGElement;
79+
80+
// Note: intentionally not [HTMLConstructor]
81+
[Exposed=Window]
82+
interface HTMLUnknownElement : HTMLElement { };
83+
84+
interface mixin HTMLOrSVGElement {
85+
[SameObject] readonly attribute DOMStringMap dataset;
86+
attribute DOMString nonce;
87+
88+
[CEReactions] attribute long tabIndex;
89+
void focus(optional FocusOptions options);
90+
void blur();
91+
};
92+
93+
[Exposed=Window,
94+
OverrideBuiltins]
95+
interface DOMStringMap {
96+
getter DOMString (DOMString name);
97+
[CEReactions] setter void (DOMString name, DOMString value);
98+
[CEReactions] deleter void (DOMString name);
99+
};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
"url": "https://html.spec.whatwg.org/multipage/custom-elements.html",
5757
"title": "HTML - Custom elements"
5858
},
59+
{
60+
"url": "https://html.spec.whatwg.org/multipage/dom.html",
61+
"title": "HTML - DOM"
62+
},
5963
{
6064
"url": "https://html.spec.whatwg.org/multipage/dnd.html",
6165
"title": "HTML - Drag and drop"

0 commit comments

Comments
 (0)