Skip to content

Commit ce1df18

Browse files
committed
add HTML grouping content types
1 parent acf9e8d commit ce1df18

File tree

8 files changed

+163
-17
lines changed

8 files changed

+163
-17
lines changed

baselines/dom.generated.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4603,6 +4603,8 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent
46034603
* @param tagName The name of an element.
46044604
*/
46054605
createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];
4606+
/** @deprecated */
4607+
createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementDeprecatedTagNameMap[K];
46064608
createElement(tagName: string, options?: ElementCreationOptions): HTMLElement;
46074609
createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement;
46084610
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement;
@@ -6022,10 +6024,6 @@ interface HTMLDivElement extends HTMLElement {
60226024
*/
60236025
/** @deprecated */
60246026
align: string;
6025-
/**
6026-
* Sets or retrieves whether the browser automatically performs wordwrap.
6027-
*/
6028-
noWrap: boolean;
60296027
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
60306028
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
60316029
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -7384,7 +7382,6 @@ declare var HTMLMediaElement: {
73847382
interface HTMLMenuElement extends HTMLElement {
73857383
/** @deprecated */
73867384
compact: boolean;
7387-
type: string;
73887385
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
73897386
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
73907387
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -7477,6 +7474,7 @@ declare var HTMLModElement: {
74777474
interface HTMLOListElement extends HTMLElement {
74787475
/** @deprecated */
74797476
compact: boolean;
7477+
reversed: boolean;
74807478
/**
74817479
* The starting number.
74827480
*/
@@ -7741,7 +7739,6 @@ interface HTMLParagraphElement extends HTMLElement {
77417739
*/
77427740
/** @deprecated */
77437741
align: string;
7744-
clear: string;
77457742
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
77467743
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
77477744
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -16778,7 +16775,6 @@ interface HTMLElementTagNameMap {
1677816775
"legend": HTMLLegendElement;
1677916776
"li": HTMLLIElement;
1678016777
"link": HTMLLinkElement;
16781-
"listing": HTMLPreElement;
1678216778
"map": HTMLMapElement;
1678316779
"mark": HTMLElement;
1678416780
"marquee": HTMLMarqueeElement;
@@ -16836,6 +16832,10 @@ interface HTMLElementTagNameMap {
1683616832
"var": HTMLElement;
1683716833
"video": HTMLVideoElement;
1683816834
"wbr": HTMLElement;
16835+
}
16836+
16837+
interface HTMLElementDeprecatedTagNameMap {
16838+
"listing": HTMLPreElement;
1683916839
"xmp": HTMLPreElement;
1684016840
}
1684116841

inputfiles/addedTypes.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,80 @@
21232123
},
21242124
"no-interface-object": "1"
21252125
},
2126+
"HTMLDivElement": {
2127+
"element": [
2128+
{
2129+
"name": "div"
2130+
}
2131+
]
2132+
},
2133+
"HTMLDListElement": {
2134+
"element": [
2135+
{
2136+
"name": "dl"
2137+
}
2138+
]
2139+
},
2140+
"HTMLHRElement": {
2141+
"element": [
2142+
{
2143+
"name": "hr"
2144+
}
2145+
]
2146+
},
2147+
"HTMLLIElement": {
2148+
"element": [
2149+
{
2150+
"name": "li"
2151+
}
2152+
]
2153+
},
2154+
"HTMLMenuElement": {
2155+
"element": [
2156+
{
2157+
"name": "menu"
2158+
}
2159+
]
2160+
},
2161+
"HTMLOListElement": {
2162+
"element": [
2163+
{
2164+
"name": "ol"
2165+
}
2166+
]
2167+
},
2168+
"HTMLParagraphElement": {
2169+
"element": [
2170+
{
2171+
"name": "p"
2172+
}
2173+
]
2174+
},
2175+
"HTMLPreElement": {
2176+
"element": [
2177+
{
2178+
"name": "pre"
2179+
},
2180+
{
2181+
"name": "listing",
2182+
"deprecated": true
2183+
},
2184+
{
2185+
"name": "xmp",
2186+
"deprecated": true
2187+
}
2188+
]
2189+
},
2190+
"HTMLQuoteElement": {
2191+
"element": [
2192+
{
2193+
"name": "blockquote"
2194+
},
2195+
{
2196+
"name": "q"
2197+
}
2198+
]
2199+
},
21262200
"HTMLTableDataCellElement": {
21272201
"name": "HTMLTableDataCellElement",
21282202
"extends": "HTMLTableCellElement",
@@ -2153,6 +2227,13 @@
21532227
}
21542228
]
21552229
},
2230+
"HTMLUListElement": {
2231+
"element": [
2232+
{
2233+
"name": "ul"
2234+
}
2235+
]
2236+
},
21562237
"NodeSelector": {
21572238
"name": "NodeSelector",
21582239
"extends": "Object",

inputfiles/comments.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,9 +1517,6 @@
15171517
"property": {
15181518
"align": {
15191519
"comment": "/**\r\n * Sets or retrieves how the object is aligned with adjacent text.\r\n */"
1520-
},
1521-
"noWrap": {
1522-
"comment": "/**\r\n * Sets or retrieves whether the browser automatically performs wordwrap.\r\n */"
15231520
}
15241521
}
15251522
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[Exposed=Window,
2+
HTMLConstructor]
3+
interface HTMLParagraphElement : HTMLElement {};
4+
5+
[Exposed=Window,
6+
HTMLConstructor]
7+
interface HTMLHRElement : HTMLElement {};
8+
9+
[Exposed=Window,
10+
HTMLConstructor]
11+
interface HTMLPreElement : HTMLElement {};
12+
13+
[Exposed=Window,
14+
HTMLConstructor]
15+
interface HTMLQuoteElement : HTMLElement {
16+
[CEReactions] attribute USVString cite;
17+
};
18+
19+
[Exposed=Window,
20+
HTMLConstructor]
21+
interface HTMLOListElement : HTMLElement {
22+
[CEReactions] attribute boolean reversed;
23+
[CEReactions] attribute long start;
24+
[CEReactions] attribute DOMString type;
25+
};
26+
27+
[Exposed=Window,
28+
HTMLConstructor]
29+
interface HTMLUListElement : HTMLElement {};
30+
31+
[Exposed=Window,
32+
HTMLConstructor]
33+
interface HTMLMenuElement : HTMLElement {
34+
};
35+
36+
[Exposed=Window,
37+
HTMLConstructor]
38+
interface HTMLLIElement : HTMLElement {
39+
[CEReactions] attribute long value;
40+
};
41+
42+
[Exposed=Window,
43+
HTMLConstructor]
44+
interface HTMLDListElement : HTMLElement {};
45+
46+
[Exposed=Window,
47+
HTMLConstructor]
48+
interface HTMLDivElement : HTMLElement {};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
"url": "https://html.spec.whatwg.org/multipage/form-elements.html",
4444
"title": "HTML - Form elements"
4545
},
46+
{
47+
"url": "https://html.spec.whatwg.org/multipage/grouping-content.html",
48+
"title": "HTML - Grouping content"
49+
},
4650
{
4751
"url": "https://html.spec.whatwg.org/multipage/obsolete.html",
4852
"title": "HTML - Obsolete features",

src/emitter.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,24 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
177177

178178
function getTagNameToElementNameMap() {
179179
const htmlResult: Record<string, string> = {};
180+
const htmlDeprecatedResult: Record<string, string> = {};
180181
const svgResult: Record<string, string> = {};
181182
for (const i of allNonCallbackInterfaces) {
182183
if (i.element) {
183184
for (const e of i.element) {
184185
if (e.namespace === "SVG") {
185186
svgResult[e.name] = i.name;
186187
}
188+
else if (e.deprecated) {
189+
htmlDeprecatedResult[e.name] = i.name;
190+
}
187191
else {
188192
htmlResult[e.name] = i.name;
189193
}
190194
}
191195
}
192196
}
193-
return { htmlResult, svgResult };
197+
return { htmlResult, htmlDeprecatedResult, svgResult };
194198
}
195199

196200
function getExtendList(iName: string): string[] {
@@ -355,6 +359,8 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
355359
function emitCreateElementOverloads(m: Browser.Method) {
356360
if (matchSingleParamMethodSignature(m, "createElement", "Element", "string")) {
357361
printer.printLine("createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];");
362+
printer.printLine("/** @deprecated */");
363+
printer.printLine("createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementDeprecatedTagNameMap[K];");
358364
printer.printLine("createElement(tagName: string, options?: ElementCreationOptions): HTMLElement;");
359365
}
360366
}
@@ -389,8 +395,18 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
389395
function emitHTMLElementTagNameMap() {
390396
printer.printLine("interface HTMLElementTagNameMap {");
391397
printer.increaseIndent();
392-
for (const e of Object.keys(tagNameToEleName.htmlResult).sort()) {
393-
const value = tagNameToEleName.htmlResult[e];
398+
for (const [e, value] of Object.entries(tagNameToEleName.htmlResult).sort()) {
399+
printer.printLine(`"${e.toLowerCase()}": ${value};`);
400+
}
401+
printer.decreaseIndent();
402+
printer.printLine("}");
403+
printer.printLine("");
404+
}
405+
406+
function emitHTMLElementDeprecatedTagNameMap() {
407+
printer.printLine("interface HTMLElementDeprecatedTagNameMap {");
408+
printer.increaseIndent();
409+
for (const [e, value] of Object.entries(tagNameToEleName.htmlDeprecatedResult).sort()) {
394410
printer.printLine(`"${e.toLowerCase()}": ${value};`);
395411
}
396412
printer.decreaseIndent();
@@ -401,13 +417,12 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
401417
function emitSVGElementTagNameMap() {
402418
printer.printLine("interface SVGElementTagNameMap {");
403419
printer.increaseIndent();
404-
for (const e of Object.keys(tagNameToEleName.svgResult).sort()) {
420+
for (const [e, value] of Object.entries(tagNameToEleName.svgResult).sort()) {
405421
if (e in tagNameToEleName.htmlResult) {
406422
// Skip conflicting fields with HTMLElementTagNameMap
407423
// to be compatible with deprecated ElementTagNameMap
408424
continue;
409425
}
410-
const value = tagNameToEleName.svgResult[e];
411426
printer.printLine(`"${e}": ${value};`);
412427
}
413428
printer.decreaseIndent();
@@ -1012,6 +1027,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
10121027

10131028
if (flavor !== Flavor.Worker) {
10141029
emitHTMLElementTagNameMap();
1030+
emitHTMLElementDeprecatedTagNameMap();
10151031
emitSVGElementTagNameMap();
10161032
emitElementTagNameMap();
10171033
emitNamedConstructors();

src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export interface ParsedAttribute{
133133
export interface Element {
134134
name: string;
135135
namespace?: string;
136+
deprecated?: boolean;
136137
"html-self-closing"?: string;
137138
specs?: string;
138139
}

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
3+
"target": "es2017",
44
"module": "commonjs",
5-
"lib": ["es2016", "dom", "dom.iterable"],
65
"outDir": "./lib",
76
"strict": true,
87
"esModuleInterop": true,

0 commit comments

Comments
 (0)