html.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. 'use strict';
  2. const NS = (exports.NAMESPACES = {
  3. HTML: 'http://www.w3.org/1999/xhtml',
  4. MATHML: 'http://www.w3.org/1998/Math/MathML',
  5. SVG: 'http://www.w3.org/2000/svg',
  6. XLINK: 'http://www.w3.org/1999/xlink',
  7. XML: 'http://www.w3.org/XML/1998/namespace',
  8. XMLNS: 'http://www.w3.org/2000/xmlns/'
  9. });
  10. exports.ATTRS = {
  11. TYPE: 'type',
  12. ACTION: 'action',
  13. ENCODING: 'encoding',
  14. PROMPT: 'prompt',
  15. NAME: 'name',
  16. COLOR: 'color',
  17. FACE: 'face',
  18. SIZE: 'size'
  19. };
  20. exports.DOCUMENT_MODE = {
  21. NO_QUIRKS: 'no-quirks',
  22. QUIRKS: 'quirks',
  23. LIMITED_QUIRKS: 'limited-quirks'
  24. };
  25. const $ = (exports.TAG_NAMES = {
  26. A: 'a',
  27. ADDRESS: 'address',
  28. ANNOTATION_XML: 'annotation-xml',
  29. APPLET: 'applet',
  30. AREA: 'area',
  31. ARTICLE: 'article',
  32. ASIDE: 'aside',
  33. B: 'b',
  34. BASE: 'base',
  35. BASEFONT: 'basefont',
  36. BGSOUND: 'bgsound',
  37. BIG: 'big',
  38. BLOCKQUOTE: 'blockquote',
  39. BODY: 'body',
  40. BR: 'br',
  41. BUTTON: 'button',
  42. CAPTION: 'caption',
  43. CENTER: 'center',
  44. CODE: 'code',
  45. COL: 'col',
  46. COLGROUP: 'colgroup',
  47. DD: 'dd',
  48. DESC: 'desc',
  49. DETAILS: 'details',
  50. DIALOG: 'dialog',
  51. DIR: 'dir',
  52. DIV: 'div',
  53. DL: 'dl',
  54. DT: 'dt',
  55. EM: 'em',
  56. EMBED: 'embed',
  57. FIELDSET: 'fieldset',
  58. FIGCAPTION: 'figcaption',
  59. FIGURE: 'figure',
  60. FONT: 'font',
  61. FOOTER: 'footer',
  62. FOREIGN_OBJECT: 'foreignObject',
  63. FORM: 'form',
  64. FRAME: 'frame',
  65. FRAMESET: 'frameset',
  66. H1: 'h1',
  67. H2: 'h2',
  68. H3: 'h3',
  69. H4: 'h4',
  70. H5: 'h5',
  71. H6: 'h6',
  72. HEAD: 'head',
  73. HEADER: 'header',
  74. HGROUP: 'hgroup',
  75. HR: 'hr',
  76. HTML: 'html',
  77. I: 'i',
  78. IMG: 'img',
  79. IMAGE: 'image',
  80. INPUT: 'input',
  81. IFRAME: 'iframe',
  82. KEYGEN: 'keygen',
  83. LABEL: 'label',
  84. LI: 'li',
  85. LINK: 'link',
  86. LISTING: 'listing',
  87. MAIN: 'main',
  88. MALIGNMARK: 'malignmark',
  89. MARQUEE: 'marquee',
  90. MATH: 'math',
  91. MENU: 'menu',
  92. META: 'meta',
  93. MGLYPH: 'mglyph',
  94. MI: 'mi',
  95. MO: 'mo',
  96. MN: 'mn',
  97. MS: 'ms',
  98. MTEXT: 'mtext',
  99. NAV: 'nav',
  100. NOBR: 'nobr',
  101. NOFRAMES: 'noframes',
  102. NOEMBED: 'noembed',
  103. NOSCRIPT: 'noscript',
  104. OBJECT: 'object',
  105. OL: 'ol',
  106. OPTGROUP: 'optgroup',
  107. OPTION: 'option',
  108. P: 'p',
  109. PARAM: 'param',
  110. PLAINTEXT: 'plaintext',
  111. PRE: 'pre',
  112. RB: 'rb',
  113. RP: 'rp',
  114. RT: 'rt',
  115. RTC: 'rtc',
  116. RUBY: 'ruby',
  117. S: 's',
  118. SCRIPT: 'script',
  119. SECTION: 'section',
  120. SELECT: 'select',
  121. SOURCE: 'source',
  122. SMALL: 'small',
  123. SPAN: 'span',
  124. STRIKE: 'strike',
  125. STRONG: 'strong',
  126. STYLE: 'style',
  127. SUB: 'sub',
  128. SUMMARY: 'summary',
  129. SUP: 'sup',
  130. TABLE: 'table',
  131. TBODY: 'tbody',
  132. TEMPLATE: 'template',
  133. TEXTAREA: 'textarea',
  134. TFOOT: 'tfoot',
  135. TD: 'td',
  136. TH: 'th',
  137. THEAD: 'thead',
  138. TITLE: 'title',
  139. TR: 'tr',
  140. TRACK: 'track',
  141. TT: 'tt',
  142. U: 'u',
  143. UL: 'ul',
  144. SVG: 'svg',
  145. VAR: 'var',
  146. WBR: 'wbr',
  147. XMP: 'xmp'
  148. });
  149. exports.SPECIAL_ELEMENTS = {
  150. [NS.HTML]: {
  151. [$.ADDRESS]: true,
  152. [$.APPLET]: true,
  153. [$.AREA]: true,
  154. [$.ARTICLE]: true,
  155. [$.ASIDE]: true,
  156. [$.BASE]: true,
  157. [$.BASEFONT]: true,
  158. [$.BGSOUND]: true,
  159. [$.BLOCKQUOTE]: true,
  160. [$.BODY]: true,
  161. [$.BR]: true,
  162. [$.BUTTON]: true,
  163. [$.CAPTION]: true,
  164. [$.CENTER]: true,
  165. [$.COL]: true,
  166. [$.COLGROUP]: true,
  167. [$.DD]: true,
  168. [$.DETAILS]: true,
  169. [$.DIR]: true,
  170. [$.DIV]: true,
  171. [$.DL]: true,
  172. [$.DT]: true,
  173. [$.EMBED]: true,
  174. [$.FIELDSET]: true,
  175. [$.FIGCAPTION]: true,
  176. [$.FIGURE]: true,
  177. [$.FOOTER]: true,
  178. [$.FORM]: true,
  179. [$.FRAME]: true,
  180. [$.FRAMESET]: true,
  181. [$.H1]: true,
  182. [$.H2]: true,
  183. [$.H3]: true,
  184. [$.H4]: true,
  185. [$.H5]: true,
  186. [$.H6]: true,
  187. [$.HEAD]: true,
  188. [$.HEADER]: true,
  189. [$.HGROUP]: true,
  190. [$.HR]: true,
  191. [$.HTML]: true,
  192. [$.IFRAME]: true,
  193. [$.IMG]: true,
  194. [$.INPUT]: true,
  195. [$.LI]: true,
  196. [$.LINK]: true,
  197. [$.LISTING]: true,
  198. [$.MAIN]: true,
  199. [$.MARQUEE]: true,
  200. [$.MENU]: true,
  201. [$.META]: true,
  202. [$.NAV]: true,
  203. [$.NOEMBED]: true,
  204. [$.NOFRAMES]: true,
  205. [$.NOSCRIPT]: true,
  206. [$.OBJECT]: true,
  207. [$.OL]: true,
  208. [$.P]: true,
  209. [$.PARAM]: true,
  210. [$.PLAINTEXT]: true,
  211. [$.PRE]: true,
  212. [$.SCRIPT]: true,
  213. [$.SECTION]: true,
  214. [$.SELECT]: true,
  215. [$.SOURCE]: true,
  216. [$.STYLE]: true,
  217. [$.SUMMARY]: true,
  218. [$.TABLE]: true,
  219. [$.TBODY]: true,
  220. [$.TD]: true,
  221. [$.TEMPLATE]: true,
  222. [$.TEXTAREA]: true,
  223. [$.TFOOT]: true,
  224. [$.TH]: true,
  225. [$.THEAD]: true,
  226. [$.TITLE]: true,
  227. [$.TR]: true,
  228. [$.TRACK]: true,
  229. [$.UL]: true,
  230. [$.WBR]: true,
  231. [$.XMP]: true
  232. },
  233. [NS.MATHML]: {
  234. [$.MI]: true,
  235. [$.MO]: true,
  236. [$.MN]: true,
  237. [$.MS]: true,
  238. [$.MTEXT]: true,
  239. [$.ANNOTATION_XML]: true
  240. },
  241. [NS.SVG]: {
  242. [$.TITLE]: true,
  243. [$.FOREIGN_OBJECT]: true,
  244. [$.DESC]: true
  245. }
  246. };