Skip to content

Commit efffd35

Browse files
authored
Merge pull request #493 from saschanaz/grouping
Add HTML grouping content types
2 parents f684a65 + ce1df18 commit efffd35

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
@@ -4601,6 +4601,8 @@ interface Document extends Node, GlobalEventHandlers, ParentNode, DocumentEvent
46014601
* @param tagName The name of an element.
46024602
*/
46034603
createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];
4604+
/** @deprecated */
4605+
createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementDeprecatedTagNameMap[K];
46044606
createElement(tagName: string, options?: ElementCreationOptions): HTMLElement;
46054607
createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement;
46064608
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement;
@@ -6020,10 +6022,6 @@ interface HTMLDivElement extends HTMLElement {
60206022
*/
60216023
/** @deprecated */
60226024
align: string;
6023-
/**
6024-
* Sets or retrieves whether the browser automatically performs wordwrap.
6025-
*/
6026-
noWrap: boolean;
60276025
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
60286026
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
60296027
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -7382,7 +7380,6 @@ declare var HTMLMediaElement: {
73827380
interface HTMLMenuElement extends HTMLElement {
73837381
/** @deprecated */
73847382
compact: boolean;
7385-
type: string;
73867383
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
73877384
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
73887385
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -7475,6 +7472,7 @@ declare var HTMLModElement: {
74757472
interface HTMLOListElement extends HTMLElement {
74767473
/** @deprecated */
74777474
compact: boolean;
7475+
reversed: boolean;
74787476
/**
74797477
* The starting number.
74807478
*/
@@ -7739,7 +7737,6 @@ interface HTMLParagraphElement extends HTMLElement {
77397737
*/
77407738
/** @deprecated */
77417739
align: string;
7742-
clear: string;
77437740
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
77447741
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
77457742
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -16777,7 +16774,6 @@ interface HTMLElementTagNameMap {
1677716774
"legend": HTMLLegendElement;
1677816775
"li": HTMLLIElement;
1677916776
"link": HTMLLinkElement;
16780-
"listing": HTMLPreElement;
1678116777
"map": HTMLMapElement;
1678216778
"mark": HTMLElement;
1678316779
"marquee": HTMLMarqueeElement;
@@ -16835,6 +16831,10 @@ interface HTMLElementTagNameMap {
1683516831
"var": HTMLElement;
1683616832
"video": HTMLVideoElement;
1683716833
"wbr": HTMLElement;
16834+
}
16835+
16836+
interface HTMLElementDeprecatedTagNameMap {
16837+
"listing": HTMLPreElement;
1683816838
"xmp": HTMLPreElement;
1683916839
}
1684016840

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
@@ -48,6 +48,10 @@
4848
"url": "https://html.spec.whatwg.org/multipage/form-elements.html",
4949
"title": "HTML - Form elements"
5050
},
51+
{
52+
"url": "https://html.spec.whatwg.org/multipage/grouping-content.html",
53+
"title": "HTML - Grouping content"
54+
},
5155
{
5256
"url": "https://html.spec.whatwg.org/multipage/obsolete.html",
5357
"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[] {
@@ -354,6 +358,8 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
354358
function emitCreateElementOverloads(m: Browser.Method) {
355359
if (matchSingleParamMethodSignature(m, "createElement", "Element", "string")) {
356360
printer.printLine("createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];");
361+
printer.printLine("/** @deprecated */");
362+
printer.printLine("createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementDeprecatedTagNameMap[K];");
357363
printer.printLine("createElement(tagName: string, options?: ElementCreationOptions): HTMLElement;");
358364
}
359365
}
@@ -388,8 +394,18 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
388394
function emitHTMLElementTagNameMap() {
389395
printer.printLine("interface HTMLElementTagNameMap {");
390396
printer.increaseIndent();
391-
for (const e of Object.keys(tagNameToEleName.htmlResult).sort()) {
392-
const value = tagNameToEleName.htmlResult[e];
397+
for (const [e, value] of Object.entries(tagNameToEleName.htmlResult).sort()) {
398+
printer.printLine(`"${e.toLowerCase()}": ${value};`);
399+
}
400+
printer.decreaseIndent();
401+
printer.printLine("}");
402+
printer.printLine("");
403+
}
404+
405+
function emitHTMLElementDeprecatedTagNameMap() {
406+
printer.printLine("interface HTMLElementDeprecatedTagNameMap {");
407+
printer.increaseIndent();
408+
for (const [e, value] of Object.entries(tagNameToEleName.htmlDeprecatedResult).sort()) {
393409
printer.printLine(`"${e.toLowerCase()}": ${value};`);
394410
}
395411
printer.decreaseIndent();
@@ -400,13 +416,12 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
400416
function emitSVGElementTagNameMap() {
401417
printer.printLine("interface SVGElementTagNameMap {");
402418
printer.increaseIndent();
403-
for (const e of Object.keys(tagNameToEleName.svgResult).sort()) {
419+
for (const [e, value] of Object.entries(tagNameToEleName.svgResult).sort()) {
404420
if (e in tagNameToEleName.htmlResult) {
405421
// Skip conflicting fields with HTMLElementTagNameMap
406422
// to be compatible with deprecated ElementTagNameMap
407423
continue;
408424
}
409-
const value = tagNameToEleName.svgResult[e];
410425
printer.printLine(`"${e}": ${value};`);
411426
}
412427
printer.decreaseIndent();
@@ -1011,6 +1026,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
10111026

10121027
if (flavor !== Flavor.Worker) {
10131028
emitHTMLElementTagNameMap();
1029+
emitHTMLElementDeprecatedTagNameMap();
10141030
emitSVGElementTagNameMap();
10151031
emitElementTagNameMap();
10161032
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)