1- export interface HTMLTagInfo {
1+ // https://html.spec.whatwg.org/multipage/indices.html#elements-3
2+
3+ export interface HTMLElementInfo {
24 name : string
35 description : string
46 isVoid : boolean
57}
68
7- export const HTML_TAGS : HTMLTagInfo [ ] = [
9+ export const HTML_ELEMENTS : HTMLElementInfo [ ] = [
810 { name : "a" , description : "Hyperlink" , isVoid : false } ,
911 { name : "abbr" , description : "Abbreviation" , isVoid : false } ,
12+ { name : "acronym" , description : "Acronym (deprecated)" , isVoid : false } ,
1013 { name : "address" , description : "Contact information" , isVoid : false } ,
1114 { name : "area" , description : "Image map area" , isVoid : true } ,
1215 { name : "article" , description : "Article content" , isVoid : false } ,
@@ -16,6 +19,7 @@ export const HTML_TAGS: HTMLTagInfo[] = [
1619 { name : "base" , description : "Document base URL" , isVoid : true } ,
1720 { name : "bdi" , description : "Bidirectional isolation" , isVoid : false } ,
1821 { name : "bdo" , description : "Bidirectional override" , isVoid : false } ,
22+ { name : "big" , description : "Larger text (deprecated)" , isVoid : false } ,
1923 { name : "blockquote" , description : "Block quotation" , isVoid : false } ,
2024 { name : "body" , description : "Document body" , isVoid : false } ,
2125 { name : "br" , description : "Line break" , isVoid : true } ,
@@ -67,6 +71,7 @@ export const HTML_TAGS: HTMLTagInfo[] = [
6771 { name : "main" , description : "Main content" , isVoid : false } ,
6872 { name : "map" , description : "Image map" , isVoid : false } ,
6973 { name : "mark" , description : "Highlighted text" , isVoid : false } ,
74+ { name : "math" , description : "MathML content" , isVoid : false } ,
7075 { name : "menu" , description : "Menu" , isVoid : false } ,
7176 { name : "meta" , description : "Metadata" , isVoid : true } ,
7277 { name : "meter" , description : "Scalar measurement" , isVoid : false } ,
@@ -78,6 +83,7 @@ export const HTML_TAGS: HTMLTagInfo[] = [
7883 { name : "option" , description : "Select option" , isVoid : false } ,
7984 { name : "output" , description : "Output result" , isVoid : false } ,
8085 { name : "p" , description : "Paragraph" , isVoid : false } ,
86+ { name : "param" , description : "Object parameter (deprecated)" , isVoid : true } ,
8187 { name : "picture" , description : "Responsive image" , isVoid : false } ,
8288 { name : "pre" , description : "Preformatted text" , isVoid : false } ,
8389 { name : "progress" , description : "Progress indicator" , isVoid : false } ,
@@ -91,6 +97,7 @@ export const HTML_TAGS: HTMLTagInfo[] = [
9197 { name : "search" , description : "Search section" , isVoid : false } ,
9298 { name : "section" , description : "Document section" , isVoid : false } ,
9399 { name : "select" , description : "Select control" , isVoid : false } ,
100+ { name : "selectedcontent" , description : "Selected content placeholder" , isVoid : false } ,
94101 { name : "slot" , description : "Web component slot" , isVoid : false } ,
95102 { name : "small" , description : "Small text" , isVoid : false } ,
96103 { name : "source" , description : "Media source" , isVoid : true } ,
@@ -100,6 +107,7 @@ export const HTML_TAGS: HTMLTagInfo[] = [
100107 { name : "sub" , description : "Subscript" , isVoid : false } ,
101108 { name : "summary" , description : "Disclosure summary" , isVoid : false } ,
102109 { name : "sup" , description : "Superscript" , isVoid : false } ,
110+ { name : "svg" , description : "SVG content" , isVoid : false } ,
103111 { name : "table" , description : "Table" , isVoid : false } ,
104112 { name : "tbody" , description : "Table body" , isVoid : false } ,
105113 { name : "td" , description : "Table cell" , isVoid : false } ,
@@ -112,9 +120,28 @@ export const HTML_TAGS: HTMLTagInfo[] = [
112120 { name : "title" , description : "Document title" , isVoid : false } ,
113121 { name : "tr" , description : "Table row" , isVoid : false } ,
114122 { name : "track" , description : "Text track" , isVoid : true } ,
123+ { name : "tt" , description : "Teletype text (deprecated)" , isVoid : false } ,
115124 { name : "u" , description : "Underline" , isVoid : false } ,
116125 { name : "ul" , description : "Unordered list" , isVoid : false } ,
117126 { name : "var" , description : "Variable" , isVoid : false } ,
118127 { name : "video" , description : "Video content" , isVoid : false } ,
119128 { name : "wbr" , description : "Word break opportunity" , isVoid : true } ,
120129]
130+
131+ export const HTML_ELEMENT_NAMES = new Set ( HTML_ELEMENTS . map ( element => element . name ) )
132+
133+ export const HTML_VOID_ELEMENTS = new Set (
134+ HTML_ELEMENTS . filter ( element => element . isVoid ) . map ( element => element . name ) ,
135+ )
136+
137+ export function isKnownHTMLElement ( tagName : string ) : boolean {
138+ return HTML_ELEMENT_NAMES . has ( tagName . toLowerCase ( ) )
139+ }
140+
141+ export function isVoidElement ( tagName : string ) : boolean {
142+ return HTML_VOID_ELEMENTS . has ( tagName . toLowerCase ( ) )
143+ }
144+
145+ export function isCustomElement ( tagName : string ) : boolean {
146+ return tagName . includes ( "-" )
147+ }
0 commit comments