html.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. /** All valid namespaces in HTML. */
  2. export var NS;
  3. (function (NS) {
  4. NS["HTML"] = "http://www.w3.org/1999/xhtml";
  5. NS["MATHML"] = "http://www.w3.org/1998/Math/MathML";
  6. NS["SVG"] = "http://www.w3.org/2000/svg";
  7. NS["XLINK"] = "http://www.w3.org/1999/xlink";
  8. NS["XML"] = "http://www.w3.org/XML/1998/namespace";
  9. NS["XMLNS"] = "http://www.w3.org/2000/xmlns/";
  10. })(NS || (NS = {}));
  11. export var ATTRS;
  12. (function (ATTRS) {
  13. ATTRS["TYPE"] = "type";
  14. ATTRS["ACTION"] = "action";
  15. ATTRS["ENCODING"] = "encoding";
  16. ATTRS["PROMPT"] = "prompt";
  17. ATTRS["NAME"] = "name";
  18. ATTRS["COLOR"] = "color";
  19. ATTRS["FACE"] = "face";
  20. ATTRS["SIZE"] = "size";
  21. })(ATTRS || (ATTRS = {}));
  22. /**
  23. * The mode of the document.
  24. *
  25. * @see {@link https://dom.spec.whatwg.org/#concept-document-limited-quirks}
  26. */
  27. export var DOCUMENT_MODE;
  28. (function (DOCUMENT_MODE) {
  29. DOCUMENT_MODE["NO_QUIRKS"] = "no-quirks";
  30. DOCUMENT_MODE["QUIRKS"] = "quirks";
  31. DOCUMENT_MODE["LIMITED_QUIRKS"] = "limited-quirks";
  32. })(DOCUMENT_MODE || (DOCUMENT_MODE = {}));
  33. export var TAG_NAMES;
  34. (function (TAG_NAMES) {
  35. TAG_NAMES["A"] = "a";
  36. TAG_NAMES["ADDRESS"] = "address";
  37. TAG_NAMES["ANNOTATION_XML"] = "annotation-xml";
  38. TAG_NAMES["APPLET"] = "applet";
  39. TAG_NAMES["AREA"] = "area";
  40. TAG_NAMES["ARTICLE"] = "article";
  41. TAG_NAMES["ASIDE"] = "aside";
  42. TAG_NAMES["B"] = "b";
  43. TAG_NAMES["BASE"] = "base";
  44. TAG_NAMES["BASEFONT"] = "basefont";
  45. TAG_NAMES["BGSOUND"] = "bgsound";
  46. TAG_NAMES["BIG"] = "big";
  47. TAG_NAMES["BLOCKQUOTE"] = "blockquote";
  48. TAG_NAMES["BODY"] = "body";
  49. TAG_NAMES["BR"] = "br";
  50. TAG_NAMES["BUTTON"] = "button";
  51. TAG_NAMES["CAPTION"] = "caption";
  52. TAG_NAMES["CENTER"] = "center";
  53. TAG_NAMES["CODE"] = "code";
  54. TAG_NAMES["COL"] = "col";
  55. TAG_NAMES["COLGROUP"] = "colgroup";
  56. TAG_NAMES["DD"] = "dd";
  57. TAG_NAMES["DESC"] = "desc";
  58. TAG_NAMES["DETAILS"] = "details";
  59. TAG_NAMES["DIALOG"] = "dialog";
  60. TAG_NAMES["DIR"] = "dir";
  61. TAG_NAMES["DIV"] = "div";
  62. TAG_NAMES["DL"] = "dl";
  63. TAG_NAMES["DT"] = "dt";
  64. TAG_NAMES["EM"] = "em";
  65. TAG_NAMES["EMBED"] = "embed";
  66. TAG_NAMES["FIELDSET"] = "fieldset";
  67. TAG_NAMES["FIGCAPTION"] = "figcaption";
  68. TAG_NAMES["FIGURE"] = "figure";
  69. TAG_NAMES["FONT"] = "font";
  70. TAG_NAMES["FOOTER"] = "footer";
  71. TAG_NAMES["FOREIGN_OBJECT"] = "foreignObject";
  72. TAG_NAMES["FORM"] = "form";
  73. TAG_NAMES["FRAME"] = "frame";
  74. TAG_NAMES["FRAMESET"] = "frameset";
  75. TAG_NAMES["H1"] = "h1";
  76. TAG_NAMES["H2"] = "h2";
  77. TAG_NAMES["H3"] = "h3";
  78. TAG_NAMES["H4"] = "h4";
  79. TAG_NAMES["H5"] = "h5";
  80. TAG_NAMES["H6"] = "h6";
  81. TAG_NAMES["HEAD"] = "head";
  82. TAG_NAMES["HEADER"] = "header";
  83. TAG_NAMES["HGROUP"] = "hgroup";
  84. TAG_NAMES["HR"] = "hr";
  85. TAG_NAMES["HTML"] = "html";
  86. TAG_NAMES["I"] = "i";
  87. TAG_NAMES["IMG"] = "img";
  88. TAG_NAMES["IMAGE"] = "image";
  89. TAG_NAMES["INPUT"] = "input";
  90. TAG_NAMES["IFRAME"] = "iframe";
  91. TAG_NAMES["KEYGEN"] = "keygen";
  92. TAG_NAMES["LABEL"] = "label";
  93. TAG_NAMES["LI"] = "li";
  94. TAG_NAMES["LINK"] = "link";
  95. TAG_NAMES["LISTING"] = "listing";
  96. TAG_NAMES["MAIN"] = "main";
  97. TAG_NAMES["MALIGNMARK"] = "malignmark";
  98. TAG_NAMES["MARQUEE"] = "marquee";
  99. TAG_NAMES["MATH"] = "math";
  100. TAG_NAMES["MENU"] = "menu";
  101. TAG_NAMES["META"] = "meta";
  102. TAG_NAMES["MGLYPH"] = "mglyph";
  103. TAG_NAMES["MI"] = "mi";
  104. TAG_NAMES["MO"] = "mo";
  105. TAG_NAMES["MN"] = "mn";
  106. TAG_NAMES["MS"] = "ms";
  107. TAG_NAMES["MTEXT"] = "mtext";
  108. TAG_NAMES["NAV"] = "nav";
  109. TAG_NAMES["NOBR"] = "nobr";
  110. TAG_NAMES["NOFRAMES"] = "noframes";
  111. TAG_NAMES["NOEMBED"] = "noembed";
  112. TAG_NAMES["NOSCRIPT"] = "noscript";
  113. TAG_NAMES["OBJECT"] = "object";
  114. TAG_NAMES["OL"] = "ol";
  115. TAG_NAMES["OPTGROUP"] = "optgroup";
  116. TAG_NAMES["OPTION"] = "option";
  117. TAG_NAMES["P"] = "p";
  118. TAG_NAMES["PARAM"] = "param";
  119. TAG_NAMES["PLAINTEXT"] = "plaintext";
  120. TAG_NAMES["PRE"] = "pre";
  121. TAG_NAMES["RB"] = "rb";
  122. TAG_NAMES["RP"] = "rp";
  123. TAG_NAMES["RT"] = "rt";
  124. TAG_NAMES["RTC"] = "rtc";
  125. TAG_NAMES["RUBY"] = "ruby";
  126. TAG_NAMES["S"] = "s";
  127. TAG_NAMES["SCRIPT"] = "script";
  128. TAG_NAMES["SEARCH"] = "search";
  129. TAG_NAMES["SECTION"] = "section";
  130. TAG_NAMES["SELECT"] = "select";
  131. TAG_NAMES["SOURCE"] = "source";
  132. TAG_NAMES["SMALL"] = "small";
  133. TAG_NAMES["SPAN"] = "span";
  134. TAG_NAMES["STRIKE"] = "strike";
  135. TAG_NAMES["STRONG"] = "strong";
  136. TAG_NAMES["STYLE"] = "style";
  137. TAG_NAMES["SUB"] = "sub";
  138. TAG_NAMES["SUMMARY"] = "summary";
  139. TAG_NAMES["SUP"] = "sup";
  140. TAG_NAMES["TABLE"] = "table";
  141. TAG_NAMES["TBODY"] = "tbody";
  142. TAG_NAMES["TEMPLATE"] = "template";
  143. TAG_NAMES["TEXTAREA"] = "textarea";
  144. TAG_NAMES["TFOOT"] = "tfoot";
  145. TAG_NAMES["TD"] = "td";
  146. TAG_NAMES["TH"] = "th";
  147. TAG_NAMES["THEAD"] = "thead";
  148. TAG_NAMES["TITLE"] = "title";
  149. TAG_NAMES["TR"] = "tr";
  150. TAG_NAMES["TRACK"] = "track";
  151. TAG_NAMES["TT"] = "tt";
  152. TAG_NAMES["U"] = "u";
  153. TAG_NAMES["UL"] = "ul";
  154. TAG_NAMES["SVG"] = "svg";
  155. TAG_NAMES["VAR"] = "var";
  156. TAG_NAMES["WBR"] = "wbr";
  157. TAG_NAMES["XMP"] = "xmp";
  158. })(TAG_NAMES || (TAG_NAMES = {}));
  159. /**
  160. * Tag IDs are numeric IDs for known tag names.
  161. *
  162. * We use tag IDs to improve the performance of tag name comparisons.
  163. */
  164. export var TAG_ID;
  165. (function (TAG_ID) {
  166. TAG_ID[TAG_ID["UNKNOWN"] = 0] = "UNKNOWN";
  167. TAG_ID[TAG_ID["A"] = 1] = "A";
  168. TAG_ID[TAG_ID["ADDRESS"] = 2] = "ADDRESS";
  169. TAG_ID[TAG_ID["ANNOTATION_XML"] = 3] = "ANNOTATION_XML";
  170. TAG_ID[TAG_ID["APPLET"] = 4] = "APPLET";
  171. TAG_ID[TAG_ID["AREA"] = 5] = "AREA";
  172. TAG_ID[TAG_ID["ARTICLE"] = 6] = "ARTICLE";
  173. TAG_ID[TAG_ID["ASIDE"] = 7] = "ASIDE";
  174. TAG_ID[TAG_ID["B"] = 8] = "B";
  175. TAG_ID[TAG_ID["BASE"] = 9] = "BASE";
  176. TAG_ID[TAG_ID["BASEFONT"] = 10] = "BASEFONT";
  177. TAG_ID[TAG_ID["BGSOUND"] = 11] = "BGSOUND";
  178. TAG_ID[TAG_ID["BIG"] = 12] = "BIG";
  179. TAG_ID[TAG_ID["BLOCKQUOTE"] = 13] = "BLOCKQUOTE";
  180. TAG_ID[TAG_ID["BODY"] = 14] = "BODY";
  181. TAG_ID[TAG_ID["BR"] = 15] = "BR";
  182. TAG_ID[TAG_ID["BUTTON"] = 16] = "BUTTON";
  183. TAG_ID[TAG_ID["CAPTION"] = 17] = "CAPTION";
  184. TAG_ID[TAG_ID["CENTER"] = 18] = "CENTER";
  185. TAG_ID[TAG_ID["CODE"] = 19] = "CODE";
  186. TAG_ID[TAG_ID["COL"] = 20] = "COL";
  187. TAG_ID[TAG_ID["COLGROUP"] = 21] = "COLGROUP";
  188. TAG_ID[TAG_ID["DD"] = 22] = "DD";
  189. TAG_ID[TAG_ID["DESC"] = 23] = "DESC";
  190. TAG_ID[TAG_ID["DETAILS"] = 24] = "DETAILS";
  191. TAG_ID[TAG_ID["DIALOG"] = 25] = "DIALOG";
  192. TAG_ID[TAG_ID["DIR"] = 26] = "DIR";
  193. TAG_ID[TAG_ID["DIV"] = 27] = "DIV";
  194. TAG_ID[TAG_ID["DL"] = 28] = "DL";
  195. TAG_ID[TAG_ID["DT"] = 29] = "DT";
  196. TAG_ID[TAG_ID["EM"] = 30] = "EM";
  197. TAG_ID[TAG_ID["EMBED"] = 31] = "EMBED";
  198. TAG_ID[TAG_ID["FIELDSET"] = 32] = "FIELDSET";
  199. TAG_ID[TAG_ID["FIGCAPTION"] = 33] = "FIGCAPTION";
  200. TAG_ID[TAG_ID["FIGURE"] = 34] = "FIGURE";
  201. TAG_ID[TAG_ID["FONT"] = 35] = "FONT";
  202. TAG_ID[TAG_ID["FOOTER"] = 36] = "FOOTER";
  203. TAG_ID[TAG_ID["FOREIGN_OBJECT"] = 37] = "FOREIGN_OBJECT";
  204. TAG_ID[TAG_ID["FORM"] = 38] = "FORM";
  205. TAG_ID[TAG_ID["FRAME"] = 39] = "FRAME";
  206. TAG_ID[TAG_ID["FRAMESET"] = 40] = "FRAMESET";
  207. TAG_ID[TAG_ID["H1"] = 41] = "H1";
  208. TAG_ID[TAG_ID["H2"] = 42] = "H2";
  209. TAG_ID[TAG_ID["H3"] = 43] = "H3";
  210. TAG_ID[TAG_ID["H4"] = 44] = "H4";
  211. TAG_ID[TAG_ID["H5"] = 45] = "H5";
  212. TAG_ID[TAG_ID["H6"] = 46] = "H6";
  213. TAG_ID[TAG_ID["HEAD"] = 47] = "HEAD";
  214. TAG_ID[TAG_ID["HEADER"] = 48] = "HEADER";
  215. TAG_ID[TAG_ID["HGROUP"] = 49] = "HGROUP";
  216. TAG_ID[TAG_ID["HR"] = 50] = "HR";
  217. TAG_ID[TAG_ID["HTML"] = 51] = "HTML";
  218. TAG_ID[TAG_ID["I"] = 52] = "I";
  219. TAG_ID[TAG_ID["IMG"] = 53] = "IMG";
  220. TAG_ID[TAG_ID["IMAGE"] = 54] = "IMAGE";
  221. TAG_ID[TAG_ID["INPUT"] = 55] = "INPUT";
  222. TAG_ID[TAG_ID["IFRAME"] = 56] = "IFRAME";
  223. TAG_ID[TAG_ID["KEYGEN"] = 57] = "KEYGEN";
  224. TAG_ID[TAG_ID["LABEL"] = 58] = "LABEL";
  225. TAG_ID[TAG_ID["LI"] = 59] = "LI";
  226. TAG_ID[TAG_ID["LINK"] = 60] = "LINK";
  227. TAG_ID[TAG_ID["LISTING"] = 61] = "LISTING";
  228. TAG_ID[TAG_ID["MAIN"] = 62] = "MAIN";
  229. TAG_ID[TAG_ID["MALIGNMARK"] = 63] = "MALIGNMARK";
  230. TAG_ID[TAG_ID["MARQUEE"] = 64] = "MARQUEE";
  231. TAG_ID[TAG_ID["MATH"] = 65] = "MATH";
  232. TAG_ID[TAG_ID["MENU"] = 66] = "MENU";
  233. TAG_ID[TAG_ID["META"] = 67] = "META";
  234. TAG_ID[TAG_ID["MGLYPH"] = 68] = "MGLYPH";
  235. TAG_ID[TAG_ID["MI"] = 69] = "MI";
  236. TAG_ID[TAG_ID["MO"] = 70] = "MO";
  237. TAG_ID[TAG_ID["MN"] = 71] = "MN";
  238. TAG_ID[TAG_ID["MS"] = 72] = "MS";
  239. TAG_ID[TAG_ID["MTEXT"] = 73] = "MTEXT";
  240. TAG_ID[TAG_ID["NAV"] = 74] = "NAV";
  241. TAG_ID[TAG_ID["NOBR"] = 75] = "NOBR";
  242. TAG_ID[TAG_ID["NOFRAMES"] = 76] = "NOFRAMES";
  243. TAG_ID[TAG_ID["NOEMBED"] = 77] = "NOEMBED";
  244. TAG_ID[TAG_ID["NOSCRIPT"] = 78] = "NOSCRIPT";
  245. TAG_ID[TAG_ID["OBJECT"] = 79] = "OBJECT";
  246. TAG_ID[TAG_ID["OL"] = 80] = "OL";
  247. TAG_ID[TAG_ID["OPTGROUP"] = 81] = "OPTGROUP";
  248. TAG_ID[TAG_ID["OPTION"] = 82] = "OPTION";
  249. TAG_ID[TAG_ID["P"] = 83] = "P";
  250. TAG_ID[TAG_ID["PARAM"] = 84] = "PARAM";
  251. TAG_ID[TAG_ID["PLAINTEXT"] = 85] = "PLAINTEXT";
  252. TAG_ID[TAG_ID["PRE"] = 86] = "PRE";
  253. TAG_ID[TAG_ID["RB"] = 87] = "RB";
  254. TAG_ID[TAG_ID["RP"] = 88] = "RP";
  255. TAG_ID[TAG_ID["RT"] = 89] = "RT";
  256. TAG_ID[TAG_ID["RTC"] = 90] = "RTC";
  257. TAG_ID[TAG_ID["RUBY"] = 91] = "RUBY";
  258. TAG_ID[TAG_ID["S"] = 92] = "S";
  259. TAG_ID[TAG_ID["SCRIPT"] = 93] = "SCRIPT";
  260. TAG_ID[TAG_ID["SEARCH"] = 94] = "SEARCH";
  261. TAG_ID[TAG_ID["SECTION"] = 95] = "SECTION";
  262. TAG_ID[TAG_ID["SELECT"] = 96] = "SELECT";
  263. TAG_ID[TAG_ID["SOURCE"] = 97] = "SOURCE";
  264. TAG_ID[TAG_ID["SMALL"] = 98] = "SMALL";
  265. TAG_ID[TAG_ID["SPAN"] = 99] = "SPAN";
  266. TAG_ID[TAG_ID["STRIKE"] = 100] = "STRIKE";
  267. TAG_ID[TAG_ID["STRONG"] = 101] = "STRONG";
  268. TAG_ID[TAG_ID["STYLE"] = 102] = "STYLE";
  269. TAG_ID[TAG_ID["SUB"] = 103] = "SUB";
  270. TAG_ID[TAG_ID["SUMMARY"] = 104] = "SUMMARY";
  271. TAG_ID[TAG_ID["SUP"] = 105] = "SUP";
  272. TAG_ID[TAG_ID["TABLE"] = 106] = "TABLE";
  273. TAG_ID[TAG_ID["TBODY"] = 107] = "TBODY";
  274. TAG_ID[TAG_ID["TEMPLATE"] = 108] = "TEMPLATE";
  275. TAG_ID[TAG_ID["TEXTAREA"] = 109] = "TEXTAREA";
  276. TAG_ID[TAG_ID["TFOOT"] = 110] = "TFOOT";
  277. TAG_ID[TAG_ID["TD"] = 111] = "TD";
  278. TAG_ID[TAG_ID["TH"] = 112] = "TH";
  279. TAG_ID[TAG_ID["THEAD"] = 113] = "THEAD";
  280. TAG_ID[TAG_ID["TITLE"] = 114] = "TITLE";
  281. TAG_ID[TAG_ID["TR"] = 115] = "TR";
  282. TAG_ID[TAG_ID["TRACK"] = 116] = "TRACK";
  283. TAG_ID[TAG_ID["TT"] = 117] = "TT";
  284. TAG_ID[TAG_ID["U"] = 118] = "U";
  285. TAG_ID[TAG_ID["UL"] = 119] = "UL";
  286. TAG_ID[TAG_ID["SVG"] = 120] = "SVG";
  287. TAG_ID[TAG_ID["VAR"] = 121] = "VAR";
  288. TAG_ID[TAG_ID["WBR"] = 122] = "WBR";
  289. TAG_ID[TAG_ID["XMP"] = 123] = "XMP";
  290. })(TAG_ID || (TAG_ID = {}));
  291. const TAG_NAME_TO_ID = new Map([
  292. [TAG_NAMES.A, TAG_ID.A],
  293. [TAG_NAMES.ADDRESS, TAG_ID.ADDRESS],
  294. [TAG_NAMES.ANNOTATION_XML, TAG_ID.ANNOTATION_XML],
  295. [TAG_NAMES.APPLET, TAG_ID.APPLET],
  296. [TAG_NAMES.AREA, TAG_ID.AREA],
  297. [TAG_NAMES.ARTICLE, TAG_ID.ARTICLE],
  298. [TAG_NAMES.ASIDE, TAG_ID.ASIDE],
  299. [TAG_NAMES.B, TAG_ID.B],
  300. [TAG_NAMES.BASE, TAG_ID.BASE],
  301. [TAG_NAMES.BASEFONT, TAG_ID.BASEFONT],
  302. [TAG_NAMES.BGSOUND, TAG_ID.BGSOUND],
  303. [TAG_NAMES.BIG, TAG_ID.BIG],
  304. [TAG_NAMES.BLOCKQUOTE, TAG_ID.BLOCKQUOTE],
  305. [TAG_NAMES.BODY, TAG_ID.BODY],
  306. [TAG_NAMES.BR, TAG_ID.BR],
  307. [TAG_NAMES.BUTTON, TAG_ID.BUTTON],
  308. [TAG_NAMES.CAPTION, TAG_ID.CAPTION],
  309. [TAG_NAMES.CENTER, TAG_ID.CENTER],
  310. [TAG_NAMES.CODE, TAG_ID.CODE],
  311. [TAG_NAMES.COL, TAG_ID.COL],
  312. [TAG_NAMES.COLGROUP, TAG_ID.COLGROUP],
  313. [TAG_NAMES.DD, TAG_ID.DD],
  314. [TAG_NAMES.DESC, TAG_ID.DESC],
  315. [TAG_NAMES.DETAILS, TAG_ID.DETAILS],
  316. [TAG_NAMES.DIALOG, TAG_ID.DIALOG],
  317. [TAG_NAMES.DIR, TAG_ID.DIR],
  318. [TAG_NAMES.DIV, TAG_ID.DIV],
  319. [TAG_NAMES.DL, TAG_ID.DL],
  320. [TAG_NAMES.DT, TAG_ID.DT],
  321. [TAG_NAMES.EM, TAG_ID.EM],
  322. [TAG_NAMES.EMBED, TAG_ID.EMBED],
  323. [TAG_NAMES.FIELDSET, TAG_ID.FIELDSET],
  324. [TAG_NAMES.FIGCAPTION, TAG_ID.FIGCAPTION],
  325. [TAG_NAMES.FIGURE, TAG_ID.FIGURE],
  326. [TAG_NAMES.FONT, TAG_ID.FONT],
  327. [TAG_NAMES.FOOTER, TAG_ID.FOOTER],
  328. [TAG_NAMES.FOREIGN_OBJECT, TAG_ID.FOREIGN_OBJECT],
  329. [TAG_NAMES.FORM, TAG_ID.FORM],
  330. [TAG_NAMES.FRAME, TAG_ID.FRAME],
  331. [TAG_NAMES.FRAMESET, TAG_ID.FRAMESET],
  332. [TAG_NAMES.H1, TAG_ID.H1],
  333. [TAG_NAMES.H2, TAG_ID.H2],
  334. [TAG_NAMES.H3, TAG_ID.H3],
  335. [TAG_NAMES.H4, TAG_ID.H4],
  336. [TAG_NAMES.H5, TAG_ID.H5],
  337. [TAG_NAMES.H6, TAG_ID.H6],
  338. [TAG_NAMES.HEAD, TAG_ID.HEAD],
  339. [TAG_NAMES.HEADER, TAG_ID.HEADER],
  340. [TAG_NAMES.HGROUP, TAG_ID.HGROUP],
  341. [TAG_NAMES.HR, TAG_ID.HR],
  342. [TAG_NAMES.HTML, TAG_ID.HTML],
  343. [TAG_NAMES.I, TAG_ID.I],
  344. [TAG_NAMES.IMG, TAG_ID.IMG],
  345. [TAG_NAMES.IMAGE, TAG_ID.IMAGE],
  346. [TAG_NAMES.INPUT, TAG_ID.INPUT],
  347. [TAG_NAMES.IFRAME, TAG_ID.IFRAME],
  348. [TAG_NAMES.KEYGEN, TAG_ID.KEYGEN],
  349. [TAG_NAMES.LABEL, TAG_ID.LABEL],
  350. [TAG_NAMES.LI, TAG_ID.LI],
  351. [TAG_NAMES.LINK, TAG_ID.LINK],
  352. [TAG_NAMES.LISTING, TAG_ID.LISTING],
  353. [TAG_NAMES.MAIN, TAG_ID.MAIN],
  354. [TAG_NAMES.MALIGNMARK, TAG_ID.MALIGNMARK],
  355. [TAG_NAMES.MARQUEE, TAG_ID.MARQUEE],
  356. [TAG_NAMES.MATH, TAG_ID.MATH],
  357. [TAG_NAMES.MENU, TAG_ID.MENU],
  358. [TAG_NAMES.META, TAG_ID.META],
  359. [TAG_NAMES.MGLYPH, TAG_ID.MGLYPH],
  360. [TAG_NAMES.MI, TAG_ID.MI],
  361. [TAG_NAMES.MO, TAG_ID.MO],
  362. [TAG_NAMES.MN, TAG_ID.MN],
  363. [TAG_NAMES.MS, TAG_ID.MS],
  364. [TAG_NAMES.MTEXT, TAG_ID.MTEXT],
  365. [TAG_NAMES.NAV, TAG_ID.NAV],
  366. [TAG_NAMES.NOBR, TAG_ID.NOBR],
  367. [TAG_NAMES.NOFRAMES, TAG_ID.NOFRAMES],
  368. [TAG_NAMES.NOEMBED, TAG_ID.NOEMBED],
  369. [TAG_NAMES.NOSCRIPT, TAG_ID.NOSCRIPT],
  370. [TAG_NAMES.OBJECT, TAG_ID.OBJECT],
  371. [TAG_NAMES.OL, TAG_ID.OL],
  372. [TAG_NAMES.OPTGROUP, TAG_ID.OPTGROUP],
  373. [TAG_NAMES.OPTION, TAG_ID.OPTION],
  374. [TAG_NAMES.P, TAG_ID.P],
  375. [TAG_NAMES.PARAM, TAG_ID.PARAM],
  376. [TAG_NAMES.PLAINTEXT, TAG_ID.PLAINTEXT],
  377. [TAG_NAMES.PRE, TAG_ID.PRE],
  378. [TAG_NAMES.RB, TAG_ID.RB],
  379. [TAG_NAMES.RP, TAG_ID.RP],
  380. [TAG_NAMES.RT, TAG_ID.RT],
  381. [TAG_NAMES.RTC, TAG_ID.RTC],
  382. [TAG_NAMES.RUBY, TAG_ID.RUBY],
  383. [TAG_NAMES.S, TAG_ID.S],
  384. [TAG_NAMES.SCRIPT, TAG_ID.SCRIPT],
  385. [TAG_NAMES.SEARCH, TAG_ID.SEARCH],
  386. [TAG_NAMES.SECTION, TAG_ID.SECTION],
  387. [TAG_NAMES.SELECT, TAG_ID.SELECT],
  388. [TAG_NAMES.SOURCE, TAG_ID.SOURCE],
  389. [TAG_NAMES.SMALL, TAG_ID.SMALL],
  390. [TAG_NAMES.SPAN, TAG_ID.SPAN],
  391. [TAG_NAMES.STRIKE, TAG_ID.STRIKE],
  392. [TAG_NAMES.STRONG, TAG_ID.STRONG],
  393. [TAG_NAMES.STYLE, TAG_ID.STYLE],
  394. [TAG_NAMES.SUB, TAG_ID.SUB],
  395. [TAG_NAMES.SUMMARY, TAG_ID.SUMMARY],
  396. [TAG_NAMES.SUP, TAG_ID.SUP],
  397. [TAG_NAMES.TABLE, TAG_ID.TABLE],
  398. [TAG_NAMES.TBODY, TAG_ID.TBODY],
  399. [TAG_NAMES.TEMPLATE, TAG_ID.TEMPLATE],
  400. [TAG_NAMES.TEXTAREA, TAG_ID.TEXTAREA],
  401. [TAG_NAMES.TFOOT, TAG_ID.TFOOT],
  402. [TAG_NAMES.TD, TAG_ID.TD],
  403. [TAG_NAMES.TH, TAG_ID.TH],
  404. [TAG_NAMES.THEAD, TAG_ID.THEAD],
  405. [TAG_NAMES.TITLE, TAG_ID.TITLE],
  406. [TAG_NAMES.TR, TAG_ID.TR],
  407. [TAG_NAMES.TRACK, TAG_ID.TRACK],
  408. [TAG_NAMES.TT, TAG_ID.TT],
  409. [TAG_NAMES.U, TAG_ID.U],
  410. [TAG_NAMES.UL, TAG_ID.UL],
  411. [TAG_NAMES.SVG, TAG_ID.SVG],
  412. [TAG_NAMES.VAR, TAG_ID.VAR],
  413. [TAG_NAMES.WBR, TAG_ID.WBR],
  414. [TAG_NAMES.XMP, TAG_ID.XMP],
  415. ]);
  416. export function getTagID(tagName) {
  417. var _a;
  418. return (_a = TAG_NAME_TO_ID.get(tagName)) !== null && _a !== void 0 ? _a : TAG_ID.UNKNOWN;
  419. }
  420. const $ = TAG_ID;
  421. export const SPECIAL_ELEMENTS = {
  422. [NS.HTML]: new Set([
  423. $.ADDRESS,
  424. $.APPLET,
  425. $.AREA,
  426. $.ARTICLE,
  427. $.ASIDE,
  428. $.BASE,
  429. $.BASEFONT,
  430. $.BGSOUND,
  431. $.BLOCKQUOTE,
  432. $.BODY,
  433. $.BR,
  434. $.BUTTON,
  435. $.CAPTION,
  436. $.CENTER,
  437. $.COL,
  438. $.COLGROUP,
  439. $.DD,
  440. $.DETAILS,
  441. $.DIR,
  442. $.DIV,
  443. $.DL,
  444. $.DT,
  445. $.EMBED,
  446. $.FIELDSET,
  447. $.FIGCAPTION,
  448. $.FIGURE,
  449. $.FOOTER,
  450. $.FORM,
  451. $.FRAME,
  452. $.FRAMESET,
  453. $.H1,
  454. $.H2,
  455. $.H3,
  456. $.H4,
  457. $.H5,
  458. $.H6,
  459. $.HEAD,
  460. $.HEADER,
  461. $.HGROUP,
  462. $.HR,
  463. $.HTML,
  464. $.IFRAME,
  465. $.IMG,
  466. $.INPUT,
  467. $.LI,
  468. $.LINK,
  469. $.LISTING,
  470. $.MAIN,
  471. $.MARQUEE,
  472. $.MENU,
  473. $.META,
  474. $.NAV,
  475. $.NOEMBED,
  476. $.NOFRAMES,
  477. $.NOSCRIPT,
  478. $.OBJECT,
  479. $.OL,
  480. $.P,
  481. $.PARAM,
  482. $.PLAINTEXT,
  483. $.PRE,
  484. $.SCRIPT,
  485. $.SECTION,
  486. $.SELECT,
  487. $.SOURCE,
  488. $.STYLE,
  489. $.SUMMARY,
  490. $.TABLE,
  491. $.TBODY,
  492. $.TD,
  493. $.TEMPLATE,
  494. $.TEXTAREA,
  495. $.TFOOT,
  496. $.TH,
  497. $.THEAD,
  498. $.TITLE,
  499. $.TR,
  500. $.TRACK,
  501. $.UL,
  502. $.WBR,
  503. $.XMP,
  504. ]),
  505. [NS.MATHML]: new Set([$.MI, $.MO, $.MN, $.MS, $.MTEXT, $.ANNOTATION_XML]),
  506. [NS.SVG]: new Set([$.TITLE, $.FOREIGN_OBJECT, $.DESC]),
  507. [NS.XLINK]: new Set(),
  508. [NS.XML]: new Set(),
  509. [NS.XMLNS]: new Set(),
  510. };
  511. export const NUMBERED_HEADERS = new Set([$.H1, $.H2, $.H3, $.H4, $.H5, $.H6]);
  512. const UNESCAPED_TEXT = new Set([
  513. TAG_NAMES.STYLE,
  514. TAG_NAMES.SCRIPT,
  515. TAG_NAMES.XMP,
  516. TAG_NAMES.IFRAME,
  517. TAG_NAMES.NOEMBED,
  518. TAG_NAMES.NOFRAMES,
  519. TAG_NAMES.PLAINTEXT,
  520. ]);
  521. export function hasUnescapedText(tn, scriptingEnabled) {
  522. return UNESCAPED_TEXT.has(tn) || (scriptingEnabled && tn === TAG_NAMES.NOSCRIPT);
  523. }