html.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. 'use strict';
  2. var 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. var $ = 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. MENUITEM: 'menuitem',
  93. META: 'meta',
  94. MGLYPH: 'mglyph',
  95. MI: 'mi',
  96. MO: 'mo',
  97. MN: 'mn',
  98. MS: 'ms',
  99. MTEXT: 'mtext',
  100. NAV: 'nav',
  101. NOBR: 'nobr',
  102. NOFRAMES: 'noframes',
  103. NOEMBED: 'noembed',
  104. NOSCRIPT: 'noscript',
  105. OBJECT: 'object',
  106. OL: 'ol',
  107. OPTGROUP: 'optgroup',
  108. OPTION: 'option',
  109. P: 'p',
  110. PARAM: 'param',
  111. PLAINTEXT: 'plaintext',
  112. PRE: 'pre',
  113. RB: 'rb',
  114. RP: 'rp',
  115. RT: 'rt',
  116. RTC: 'rtc',
  117. RUBY: 'ruby',
  118. S: 's',
  119. SCRIPT: 'script',
  120. SECTION: 'section',
  121. SELECT: 'select',
  122. SOURCE: 'source',
  123. SMALL: 'small',
  124. SPAN: 'span',
  125. STRIKE: 'strike',
  126. STRONG: 'strong',
  127. STYLE: 'style',
  128. SUB: 'sub',
  129. SUMMARY: 'summary',
  130. SUP: 'sup',
  131. TABLE: 'table',
  132. TBODY: 'tbody',
  133. TEMPLATE: 'template',
  134. TEXTAREA: 'textarea',
  135. TFOOT: 'tfoot',
  136. TD: 'td',
  137. TH: 'th',
  138. THEAD: 'thead',
  139. TITLE: 'title',
  140. TR: 'tr',
  141. TRACK: 'track',
  142. TT: 'tt',
  143. U: 'u',
  144. UL: 'ul',
  145. SVG: 'svg',
  146. VAR: 'var',
  147. WBR: 'wbr',
  148. XMP: 'xmp'
  149. };
  150. var SPECIAL_ELEMENTS = exports.SPECIAL_ELEMENTS = Object.create(null);
  151. SPECIAL_ELEMENTS[NS.HTML] = Object.create(null);
  152. SPECIAL_ELEMENTS[NS.HTML][$.ADDRESS] = true;
  153. SPECIAL_ELEMENTS[NS.HTML][$.APPLET] = true;
  154. SPECIAL_ELEMENTS[NS.HTML][$.AREA] = true;
  155. SPECIAL_ELEMENTS[NS.HTML][$.ARTICLE] = true;
  156. SPECIAL_ELEMENTS[NS.HTML][$.ASIDE] = true;
  157. SPECIAL_ELEMENTS[NS.HTML][$.BASE] = true;
  158. SPECIAL_ELEMENTS[NS.HTML][$.BASEFONT] = true;
  159. SPECIAL_ELEMENTS[NS.HTML][$.BGSOUND] = true;
  160. SPECIAL_ELEMENTS[NS.HTML][$.BLOCKQUOTE] = true;
  161. SPECIAL_ELEMENTS[NS.HTML][$.BODY] = true;
  162. SPECIAL_ELEMENTS[NS.HTML][$.BR] = true;
  163. SPECIAL_ELEMENTS[NS.HTML][$.BUTTON] = true;
  164. SPECIAL_ELEMENTS[NS.HTML][$.CAPTION] = true;
  165. SPECIAL_ELEMENTS[NS.HTML][$.CENTER] = true;
  166. SPECIAL_ELEMENTS[NS.HTML][$.COL] = true;
  167. SPECIAL_ELEMENTS[NS.HTML][$.COLGROUP] = true;
  168. SPECIAL_ELEMENTS[NS.HTML][$.DD] = true;
  169. SPECIAL_ELEMENTS[NS.HTML][$.DETAILS] = true;
  170. SPECIAL_ELEMENTS[NS.HTML][$.DIR] = true;
  171. SPECIAL_ELEMENTS[NS.HTML][$.DIV] = true;
  172. SPECIAL_ELEMENTS[NS.HTML][$.DL] = true;
  173. SPECIAL_ELEMENTS[NS.HTML][$.DT] = true;
  174. SPECIAL_ELEMENTS[NS.HTML][$.EMBED] = true;
  175. SPECIAL_ELEMENTS[NS.HTML][$.FIELDSET] = true;
  176. SPECIAL_ELEMENTS[NS.HTML][$.FIGCAPTION] = true;
  177. SPECIAL_ELEMENTS[NS.HTML][$.FIGURE] = true;
  178. SPECIAL_ELEMENTS[NS.HTML][$.FOOTER] = true;
  179. SPECIAL_ELEMENTS[NS.HTML][$.FORM] = true;
  180. SPECIAL_ELEMENTS[NS.HTML][$.FRAME] = true;
  181. SPECIAL_ELEMENTS[NS.HTML][$.FRAMESET] = true;
  182. SPECIAL_ELEMENTS[NS.HTML][$.H1] = true;
  183. SPECIAL_ELEMENTS[NS.HTML][$.H2] = true;
  184. SPECIAL_ELEMENTS[NS.HTML][$.H3] = true;
  185. SPECIAL_ELEMENTS[NS.HTML][$.H4] = true;
  186. SPECIAL_ELEMENTS[NS.HTML][$.H5] = true;
  187. SPECIAL_ELEMENTS[NS.HTML][$.H6] = true;
  188. SPECIAL_ELEMENTS[NS.HTML][$.HEAD] = true;
  189. SPECIAL_ELEMENTS[NS.HTML][$.HEADER] = true;
  190. SPECIAL_ELEMENTS[NS.HTML][$.HGROUP] = true;
  191. SPECIAL_ELEMENTS[NS.HTML][$.HR] = true;
  192. SPECIAL_ELEMENTS[NS.HTML][$.HTML] = true;
  193. SPECIAL_ELEMENTS[NS.HTML][$.IFRAME] = true;
  194. SPECIAL_ELEMENTS[NS.HTML][$.IMG] = true;
  195. SPECIAL_ELEMENTS[NS.HTML][$.INPUT] = true;
  196. SPECIAL_ELEMENTS[NS.HTML][$.LI] = true;
  197. SPECIAL_ELEMENTS[NS.HTML][$.LINK] = true;
  198. SPECIAL_ELEMENTS[NS.HTML][$.LISTING] = true;
  199. SPECIAL_ELEMENTS[NS.HTML][$.MAIN] = true;
  200. SPECIAL_ELEMENTS[NS.HTML][$.MARQUEE] = true;
  201. SPECIAL_ELEMENTS[NS.HTML][$.MENU] = true;
  202. SPECIAL_ELEMENTS[NS.HTML][$.META] = true;
  203. SPECIAL_ELEMENTS[NS.HTML][$.NAV] = true;
  204. SPECIAL_ELEMENTS[NS.HTML][$.NOEMBED] = true;
  205. SPECIAL_ELEMENTS[NS.HTML][$.NOFRAMES] = true;
  206. SPECIAL_ELEMENTS[NS.HTML][$.NOSCRIPT] = true;
  207. SPECIAL_ELEMENTS[NS.HTML][$.OBJECT] = true;
  208. SPECIAL_ELEMENTS[NS.HTML][$.OL] = true;
  209. SPECIAL_ELEMENTS[NS.HTML][$.P] = true;
  210. SPECIAL_ELEMENTS[NS.HTML][$.PARAM] = true;
  211. SPECIAL_ELEMENTS[NS.HTML][$.PLAINTEXT] = true;
  212. SPECIAL_ELEMENTS[NS.HTML][$.PRE] = true;
  213. SPECIAL_ELEMENTS[NS.HTML][$.SCRIPT] = true;
  214. SPECIAL_ELEMENTS[NS.HTML][$.SECTION] = true;
  215. SPECIAL_ELEMENTS[NS.HTML][$.SELECT] = true;
  216. SPECIAL_ELEMENTS[NS.HTML][$.SOURCE] = true;
  217. SPECIAL_ELEMENTS[NS.HTML][$.STYLE] = true;
  218. SPECIAL_ELEMENTS[NS.HTML][$.SUMMARY] = true;
  219. SPECIAL_ELEMENTS[NS.HTML][$.TABLE] = true;
  220. SPECIAL_ELEMENTS[NS.HTML][$.TBODY] = true;
  221. SPECIAL_ELEMENTS[NS.HTML][$.TD] = true;
  222. SPECIAL_ELEMENTS[NS.HTML][$.TEMPLATE] = true;
  223. SPECIAL_ELEMENTS[NS.HTML][$.TEXTAREA] = true;
  224. SPECIAL_ELEMENTS[NS.HTML][$.TFOOT] = true;
  225. SPECIAL_ELEMENTS[NS.HTML][$.TH] = true;
  226. SPECIAL_ELEMENTS[NS.HTML][$.THEAD] = true;
  227. SPECIAL_ELEMENTS[NS.HTML][$.TITLE] = true;
  228. SPECIAL_ELEMENTS[NS.HTML][$.TR] = true;
  229. SPECIAL_ELEMENTS[NS.HTML][$.TRACK] = true;
  230. SPECIAL_ELEMENTS[NS.HTML][$.UL] = true;
  231. SPECIAL_ELEMENTS[NS.HTML][$.WBR] = true;
  232. SPECIAL_ELEMENTS[NS.HTML][$.XMP] = true;
  233. SPECIAL_ELEMENTS[NS.MATHML] = Object.create(null);
  234. SPECIAL_ELEMENTS[NS.MATHML][$.MI] = true;
  235. SPECIAL_ELEMENTS[NS.MATHML][$.MO] = true;
  236. SPECIAL_ELEMENTS[NS.MATHML][$.MN] = true;
  237. SPECIAL_ELEMENTS[NS.MATHML][$.MS] = true;
  238. SPECIAL_ELEMENTS[NS.MATHML][$.MTEXT] = true;
  239. SPECIAL_ELEMENTS[NS.MATHML][$.ANNOTATION_XML] = true;
  240. SPECIAL_ELEMENTS[NS.SVG] = Object.create(null);
  241. SPECIAL_ELEMENTS[NS.SVG][$.TITLE] = true;
  242. SPECIAL_ELEMENTS[NS.SVG][$.FOREIGN_OBJECT] = true;
  243. SPECIAL_ELEMENTS[NS.SVG][$.DESC] = true;