You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

272 lines
5.2 KiB

  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. };