domMap.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _iterationDecorator = _interopRequireDefault(require("./util/iterationDecorator"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  9. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  10. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  11. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  12. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  13. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  14. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  15. var dom = [['a', {
  16. reserved: false
  17. }], ['abbr', {
  18. reserved: false
  19. }], ['acronym', {
  20. reserved: false
  21. }], ['address', {
  22. reserved: false
  23. }], ['applet', {
  24. reserved: false
  25. }], ['area', {
  26. reserved: false
  27. }], ['article', {
  28. reserved: false
  29. }], ['aside', {
  30. reserved: false
  31. }], ['audio', {
  32. reserved: false
  33. }], ['b', {
  34. reserved: false
  35. }], ['base', {
  36. reserved: true
  37. }], ['bdi', {
  38. reserved: false
  39. }], ['bdo', {
  40. reserved: false
  41. }], ['big', {
  42. reserved: false
  43. }], ['blink', {
  44. reserved: false
  45. }], ['blockquote', {
  46. reserved: false
  47. }], ['body', {
  48. reserved: false
  49. }], ['br', {
  50. reserved: false
  51. }], ['button', {
  52. reserved: false
  53. }], ['canvas', {
  54. reserved: false
  55. }], ['caption', {
  56. reserved: false
  57. }], ['center', {
  58. reserved: false
  59. }], ['cite', {
  60. reserved: false
  61. }], ['code', {
  62. reserved: false
  63. }], ['col', {
  64. reserved: true
  65. }], ['colgroup', {
  66. reserved: true
  67. }], ['content', {
  68. reserved: false
  69. }], ['data', {
  70. reserved: false
  71. }], ['datalist', {
  72. reserved: false
  73. }], ['dd', {
  74. reserved: false
  75. }], ['del', {
  76. reserved: false
  77. }], ['details', {
  78. reserved: false
  79. }], ['dfn', {
  80. reserved: false
  81. }], ['dialog', {
  82. reserved: false
  83. }], ['dir', {
  84. reserved: false
  85. }], ['div', {
  86. reserved: false
  87. }], ['dl', {
  88. reserved: false
  89. }], ['dt', {
  90. reserved: false
  91. }], ['em', {
  92. reserved: false
  93. }], ['embed', {
  94. reserved: false
  95. }], ['fieldset', {
  96. reserved: false
  97. }], ['figcaption', {
  98. reserved: false
  99. }], ['figure', {
  100. reserved: false
  101. }], ['font', {
  102. reserved: false
  103. }], ['footer', {
  104. reserved: false
  105. }], ['form', {
  106. reserved: false
  107. }], ['frame', {
  108. reserved: false
  109. }], ['frameset', {
  110. reserved: false
  111. }], ['h1', {
  112. reserved: false
  113. }], ['h2', {
  114. reserved: false
  115. }], ['h3', {
  116. reserved: false
  117. }], ['h4', {
  118. reserved: false
  119. }], ['h5', {
  120. reserved: false
  121. }], ['h6', {
  122. reserved: false
  123. }], ['head', {
  124. reserved: true
  125. }], ['header', {
  126. reserved: false
  127. }], ['hgroup', {
  128. reserved: false
  129. }], ['hr', {
  130. reserved: false
  131. }], ['html', {
  132. reserved: true
  133. }], ['i', {
  134. reserved: false
  135. }], ['iframe', {
  136. reserved: false
  137. }], ['img', {
  138. reserved: false
  139. }], ['input', {
  140. reserved: false
  141. }], ['ins', {
  142. reserved: false
  143. }], ['kbd', {
  144. reserved: false
  145. }], ['keygen', {
  146. reserved: false
  147. }], ['label', {
  148. reserved: false
  149. }], ['legend', {
  150. reserved: false
  151. }], ['li', {
  152. reserved: false
  153. }], ['link', {
  154. reserved: true
  155. }], ['main', {
  156. reserved: false
  157. }], ['map', {
  158. reserved: false
  159. }], ['mark', {
  160. reserved: false
  161. }], ['marquee', {
  162. reserved: false
  163. }], ['menu', {
  164. reserved: false
  165. }], ['menuitem', {
  166. reserved: false
  167. }], ['meta', {
  168. reserved: true
  169. }], ['meter', {
  170. reserved: false
  171. }], ['nav', {
  172. reserved: false
  173. }], ['noembed', {
  174. reserved: true
  175. }], ['noscript', {
  176. reserved: true
  177. }], ['object', {
  178. reserved: false
  179. }], ['ol', {
  180. reserved: false
  181. }], ['optgroup', {
  182. reserved: false
  183. }], ['option', {
  184. reserved: false
  185. }], ['output', {
  186. reserved: false
  187. }], ['p', {
  188. reserved: false
  189. }], ['param', {
  190. reserved: true
  191. }], ['picture', {
  192. reserved: true
  193. }], ['pre', {
  194. reserved: false
  195. }], ['progress', {
  196. reserved: false
  197. }], ['q', {
  198. reserved: false
  199. }], ['rp', {
  200. reserved: false
  201. }], ['rt', {
  202. reserved: false
  203. }], ['rtc', {
  204. reserved: false
  205. }], ['ruby', {
  206. reserved: false
  207. }], ['s', {
  208. reserved: false
  209. }], ['samp', {
  210. reserved: false
  211. }], ['script', {
  212. reserved: true
  213. }], ['section', {
  214. reserved: false
  215. }], ['select', {
  216. reserved: false
  217. }], ['small', {
  218. reserved: false
  219. }], ['source', {
  220. reserved: true
  221. }], ['spacer', {
  222. reserved: false
  223. }], ['span', {
  224. reserved: false
  225. }], ['strike', {
  226. reserved: false
  227. }], ['strong', {
  228. reserved: false
  229. }], ['style', {
  230. reserved: true
  231. }], ['sub', {
  232. reserved: false
  233. }], ['summary', {
  234. reserved: false
  235. }], ['sup', {
  236. reserved: false
  237. }], ['table', {
  238. reserved: false
  239. }], ['tbody', {
  240. reserved: false
  241. }], ['td', {
  242. reserved: false
  243. }], ['textarea', {
  244. reserved: false
  245. }], ['tfoot', {
  246. reserved: false
  247. }], ['th', {
  248. reserved: false
  249. }], ['thead', {
  250. reserved: false
  251. }], ['time', {
  252. reserved: false
  253. }], ['title', {
  254. reserved: true
  255. }], ['tr', {
  256. reserved: false
  257. }], ['track', {
  258. reserved: true
  259. }], ['tt', {
  260. reserved: false
  261. }], ['u', {
  262. reserved: false
  263. }], ['ul', {
  264. reserved: false
  265. }], ['var', {
  266. reserved: false
  267. }], ['video', {
  268. reserved: false
  269. }], ['wbr', {
  270. reserved: false
  271. }], ['xmp', {
  272. reserved: false
  273. }]];
  274. var domMap = {
  275. entries: function entries() {
  276. return dom;
  277. },
  278. forEach: function forEach(fn) {
  279. var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  280. var _iterator = _createForOfIteratorHelper(dom),
  281. _step;
  282. try {
  283. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  284. var _step$value = _slicedToArray(_step.value, 2),
  285. key = _step$value[0],
  286. values = _step$value[1];
  287. fn.call(thisArg, values, key, dom);
  288. }
  289. } catch (err) {
  290. _iterator.e(err);
  291. } finally {
  292. _iterator.f();
  293. }
  294. },
  295. get: function get(key) {
  296. var item = dom.find(function (tuple) {
  297. return tuple[0] === key ? true : false;
  298. });
  299. return item && item[1];
  300. },
  301. has: function has(key) {
  302. return !!domMap.get(key);
  303. },
  304. keys: function keys() {
  305. return dom.map(function (_ref) {
  306. var _ref2 = _slicedToArray(_ref, 1),
  307. key = _ref2[0];
  308. return key;
  309. });
  310. },
  311. values: function values() {
  312. return dom.map(function (_ref3) {
  313. var _ref4 = _slicedToArray(_ref3, 2),
  314. values = _ref4[1];
  315. return values;
  316. });
  317. }
  318. };
  319. var _default = (0, _iterationDecorator.default)(domMap, domMap.entries());
  320. exports.default = _default;