@markuplint/ml-core 3.0.0-alpha.66 → 3.0.0-dev.176

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +12 -3
  2. package/lib/configs.browser.d.ts +2 -0
  3. package/lib/configs.browser.js +12 -0
  4. package/lib/configs.js +4 -1
  5. package/lib/index.d.ts +11 -1
  6. package/lib/ml-core.d.ts +24 -13
  7. package/lib/ml-core.js +16 -10
  8. package/lib/ml-dom/helper/accname.d.ts +2 -1
  9. package/lib/ml-dom/helper/accname.js +62 -2
  10. package/lib/ml-dom/helper/create-node.d.ts +7 -3
  11. package/lib/ml-dom/helper/create-node.js +4 -2
  12. package/lib/ml-dom/helper/debug.js +10 -5
  13. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  14. package/lib/ml-dom/helper/getIndent.js +18 -12
  15. package/lib/ml-dom/helper/walkers.d.ts +15 -5
  16. package/lib/ml-dom/helper/walkers.js +22 -16
  17. package/lib/ml-dom/index.d.ts +1 -0
  18. package/lib/ml-dom/manipulations/child-node-methods.d.ts +20 -7
  19. package/lib/ml-dom/manipulations/child-node-methods.js +24 -6
  20. package/lib/ml-dom/manipulations/get-children.d.ts +4 -2
  21. package/lib/ml-dom/manipulations/get-children.js +3 -1
  22. package/lib/ml-dom/node/attr.d.ts +94 -91
  23. package/lib/ml-dom/node/attr.js +26 -16
  24. package/lib/ml-dom/node/block.d.ts +36 -32
  25. package/lib/ml-dom/node/block.js +14 -4
  26. package/lib/ml-dom/node/character-data.d.ts +61 -54
  27. package/lib/ml-dom/node/character-data.js +9 -3
  28. package/lib/ml-dom/node/child-node.d.ts +10 -3
  29. package/lib/ml-dom/node/child-node.js +3 -1
  30. package/lib/ml-dom/node/comment.d.ts +16 -13
  31. package/lib/ml-dom/node/document-fragment.d.ts +24 -21
  32. package/lib/ml-dom/node/document-type.d.ts +35 -32
  33. package/lib/ml-dom/node/document-type.js +14 -4
  34. package/lib/ml-dom/node/document.d.ts +1608 -1545
  35. package/lib/ml-dom/node/document.js +125 -33
  36. package/lib/ml-dom/node/dom-token-list.d.ts +27 -27
  37. package/lib/ml-dom/node/dom-token-list.js +15 -13
  38. package/lib/ml-dom/node/element.d.ts +1906 -1817
  39. package/lib/ml-dom/node/element.js +345 -75
  40. package/lib/ml-dom/node/named-node-map.d.ts +45 -40
  41. package/lib/ml-dom/node/named-node-map.js +13 -5
  42. package/lib/ml-dom/node/node-list.d.ts +10 -4
  43. package/lib/ml-dom/node/node-list.js +25 -5
  44. package/lib/ml-dom/node/node-store.d.ts +10 -5
  45. package/lib/ml-dom/node/node-store.js +19 -1
  46. package/lib/ml-dom/node/node.d.ts +494 -467
  47. package/lib/ml-dom/node/node.js +89 -47
  48. package/lib/ml-dom/node/parent-node.d.ts +68 -59
  49. package/lib/ml-dom/node/parent-node.js +15 -6
  50. package/lib/ml-dom/node/rule-mapper.d.ts +9 -9
  51. package/lib/ml-dom/node/rule-mapper.js +11 -3
  52. package/lib/ml-dom/node/text.d.ts +50 -47
  53. package/lib/ml-dom/node/types.d.ts +94 -16
  54. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -2
  55. package/lib/ml-dom/token/token.d.ts +44 -44
  56. package/lib/ml-rule/create-rule.d.ts +4 -2
  57. package/lib/ml-rule/create-test-rule.d.ts +6 -4
  58. package/lib/ml-rule/ml-rule-context.d.ts +58 -49
  59. package/lib/ml-rule/ml-rule-context.js +23 -4
  60. package/lib/ml-rule/ml-rule.d.ts +36 -26
  61. package/lib/ml-rule/ml-rule.js +39 -34
  62. package/lib/ml-rule/types.d.ts +35 -17
  63. package/lib/plugin/plugin.d.ts +3 -1
  64. package/lib/plugin/types.d.ts +9 -9
  65. package/lib/ruleset/index.d.ts +4 -4
  66. package/lib/ruleset/index.js +4 -4
  67. package/lib/test/index.d.ts +21 -8
  68. package/lib/test/index.js +6 -4
  69. package/lib/types.d.ts +12 -10
  70. package/lib/utils/get-location-from-chars.d.ts +9 -4
  71. package/package.json +21 -15
  72. package/test/ml-dom/helper/accname.spec.js +85 -0
  73. package/test/ml-dom/helper/create-node.spec.js +18 -0
  74. package/test/ml-dom/index.spec.js +680 -0
  75. package/lib/ml-dom/document.d.ts +0 -94
  76. package/lib/ml-dom/document.js +0 -273
  77. package/lib/ml-dom/helper/index.d.ts +0 -4
  78. package/lib/ml-dom/helper/index.js +0 -12
  79. package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -52
  80. package/lib/ml-dom/helper/mapped-nodes.js +0 -2
  81. package/lib/ml-dom/helper/match-selector.d.ts +0 -20
  82. package/lib/ml-dom/helper/match-selector.js +0 -233
  83. package/lib/ml-dom/helper/node-store.d.ts +0 -12
  84. package/lib/ml-dom/helper/node-store.js +0 -28
  85. package/lib/ml-dom/helper/selector.d.ts +0 -11
  86. package/lib/ml-dom/helper/selector.js +0 -549
  87. package/lib/ml-dom/rule-mapper.d.ts +0 -16
  88. package/lib/ml-dom/rule-mapper.js +0 -57
  89. package/lib/ml-dom/tokens/abstract-element.d.ts +0 -54
  90. package/lib/ml-dom/tokens/abstract-element.js +0 -249
  91. package/lib/ml-dom/tokens/attribute.d.ts +0 -42
  92. package/lib/ml-dom/tokens/attribute.js +0 -85
  93. package/lib/ml-dom/tokens/comment.d.ts +0 -12
  94. package/lib/ml-dom/tokens/comment.js +0 -15
  95. package/lib/ml-dom/tokens/doctype.d.ts +0 -18
  96. package/lib/ml-dom/tokens/doctype.js +0 -32
  97. package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -27
  98. package/lib/ml-dom/tokens/element-close-tag.js +0 -45
  99. package/lib/ml-dom/tokens/element.d.ts +0 -26
  100. package/lib/ml-dom/tokens/element.js +0 -66
  101. package/lib/ml-dom/tokens/index.d.ts +0 -10
  102. package/lib/ml-dom/tokens/index.js +0 -26
  103. package/lib/ml-dom/tokens/node.d.ts +0 -46
  104. package/lib/ml-dom/tokens/node.js +0 -126
  105. package/lib/ml-dom/tokens/omitted-element.d.ts +0 -13
  106. package/lib/ml-dom/tokens/omitted-element.js +0 -12
  107. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
  108. package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
  109. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -14
  110. package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
  111. package/lib/ml-dom/tokens/text.d.ts +0 -19
  112. package/lib/ml-dom/tokens/text.js +0 -26
  113. package/lib/ml-dom/tokens/token.d.ts +0 -16
  114. package/lib/ml-dom/tokens/token.js +0 -55
  115. package/lib/ml-dom/types.d.ts +0 -49
  116. package/lib/ml-dom/types.js +0 -2
  117. package/lib/selector/is-pure-html-element.d.ts +0 -1
  118. package/lib/selector/is-pure-html-element.js +0 -7
  119. package/lib/selector/match-selector.d.ts +0 -14
  120. package/lib/selector/match-selector.js +0 -230
  121. package/lib/selector/selector.d.ts +0 -9
  122. package/lib/selector/selector.js +0 -561
  123. package/tsconfig.test.json +0 -3
  124. package/tsconfig.tsbuildinfo +0 -1
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
- var _MLElement_attributes, _MLElement_fixedNodeName, _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache, _MLElement_normalizedAttrs, _MLElement_normalizedString, _MLElement_tagOpenChar;
2
+ var _MLElement_attributes, _MLElement_fixedNodeName, _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache, _MLElement_localName, _MLElement_normalizedAttrs, _MLElement_normalizedString, _MLElement_tagOpenChar;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.MLElement = void 0;
5
5
  const tslib_1 = require("tslib");
6
+ const ml_spec_1 = require("@markuplint/ml-spec");
6
7
  const selector_1 = require("@markuplint/selector");
7
8
  const string_splice_1 = require("../../utils/string-splice");
8
9
  const accname_1 = require("../helper/accname");
@@ -16,28 +17,30 @@ const parent_node_1 = require("./parent-node");
16
17
  const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
17
18
  const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
18
19
  class MLElement extends parent_node_1.MLParentNode {
19
- constructor(astNode, document) {
20
- var _a;
20
+ constructor(
21
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
22
+ astNode,
23
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
24
+ document) {
21
25
  super(astNode, document);
22
26
  _MLElement_attributes.set(this, void 0);
23
27
  _MLElement_fixedNodeName.set(this, void 0);
24
28
  _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache.set(this, null);
25
- _MLElement_normalizedAttrs.set(this, null);
29
+ _MLElement_localName.set(this, void 0);
30
+ _MLElement_normalizedAttrs.set(this, new Map());
26
31
  _MLElement_normalizedString.set(this, null);
32
+ this.pretenderContext = null;
27
33
  _MLElement_tagOpenChar.set(this, void 0);
28
34
  tslib_1.__classPrivateFieldSet(this, _MLElement_attributes, astNode.attributes.map(attr => new attr_1.MLAttr(attr, this)), "f");
29
35
  this.hasSpreadAttr = astNode.hasSpreadAttr;
30
36
  this.selfClosingSolidus = astNode.selfClosingSolidus ? new token_1.MLToken(astNode.selfClosingSolidus) : null;
31
37
  this.endSpace = astNode.endSpace ? new token_1.MLToken(astNode.endSpace) : null;
32
38
  this.closeTag = astNode.pearNode ? new token_1.MLToken(astNode.pearNode) : null;
33
- this.namespaceURI =
34
- (_a = [
35
- 'http://www.w3.org/1999/xhtml',
36
- 'http://www.w3.org/2000/svg',
37
- 'http://www.w3.org/1998/Math/MathML',
38
- ].find(ns => astNode.namespace === ns)) !== null && _a !== void 0 ? _a : HTML_NAMESPACE;
39
+ const ns = (0, ml_spec_1.resolveNamespace)(astNode.nodeName, astNode.namespace);
40
+ this.namespaceURI = ns.namespaceURI;
41
+ this.elementType = astNode.elementType;
42
+ tslib_1.__classPrivateFieldSet(this, _MLElement_localName, ns.localName, "f");
39
43
  this.isForeignElement = this.namespaceURI !== HTML_NAMESPACE;
40
- this.isCustomElement = astNode.isCustomElement;
41
44
  tslib_1.__classPrivateFieldSet(this, _MLElement_fixedNodeName, astNode.nodeName, "f");
42
45
  this.isOmitted = astNode.isGhost;
43
46
  tslib_1.__classPrivateFieldSet(this, _MLElement_tagOpenChar, astNode.tagOpenChar, "f");
@@ -122,6 +125,16 @@ class MLElement extends parent_node_1.MLParentNode {
122
125
  get ariaColIndex() {
123
126
  throw new unexpected_call_error_1.default('Not supported "ariaColIndex" property');
124
127
  }
128
+ /**
129
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
130
+ *
131
+ * @deprecated
132
+ * @unsupported
133
+ * @implements DOM API: `Element`
134
+ */
135
+ get ariaColIndexText() {
136
+ throw new unexpected_call_error_1.default('Not supported "ariaColIndexText" property');
137
+ }
125
138
  /**
126
139
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
127
140
  *
@@ -182,6 +195,16 @@ class MLElement extends parent_node_1.MLParentNode {
182
195
  get ariaHidden() {
183
196
  throw new unexpected_call_error_1.default('Not supported "ariaHidden" property');
184
197
  }
198
+ /**
199
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
200
+ *
201
+ * @deprecated
202
+ * @unsupported
203
+ * @implements DOM API: `Element`
204
+ */
205
+ get ariaInvalid() {
206
+ throw new unexpected_call_error_1.default('Not supported "ariaInvalid" property');
207
+ }
185
208
  /**
186
209
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
187
210
  *
@@ -342,6 +365,16 @@ class MLElement extends parent_node_1.MLParentNode {
342
365
  get ariaRowIndex() {
343
366
  throw new unexpected_call_error_1.default('Not supported "ariaRowIndex" property');
344
367
  }
368
+ /**
369
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
370
+ *
371
+ * @deprecated
372
+ * @unsupported
373
+ * @implements DOM API: `Element`
374
+ */
375
+ get ariaRowIndexText() {
376
+ throw new unexpected_call_error_1.default('Not supported "ariaRowIndexText" property');
377
+ }
345
378
  /**
346
379
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
347
380
  *
@@ -437,12 +470,14 @@ class MLElement extends parent_node_1.MLParentNode {
437
470
  * @see https://dom.spec.whatwg.org/#dom-element-attributes
438
471
  */
439
472
  get attributes() {
440
- if (tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f")) {
441
- return tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f");
473
+ var _a;
474
+ const origin = ((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? tslib_1.__classPrivateFieldGet(this.pretenderContext.as, _MLElement_attributes, "f") : tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f");
475
+ if (tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").has(origin)) {
476
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").get(origin);
442
477
  }
443
478
  const names = new Set();
444
479
  const attrs = [];
445
- for (const attr of tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f")) {
480
+ for (const attr of origin) {
446
481
  if (names.has(attr.name)) {
447
482
  /**
448
483
  * Skips a duplicated attribute
@@ -453,8 +488,9 @@ class MLElement extends parent_node_1.MLParentNode {
453
488
  }
454
489
  attrs.push(attr);
455
490
  }
456
- tslib_1.__classPrivateFieldSet(this, _MLElement_normalizedAttrs, (0, named_node_map_1.toNamedNodeMap)(attrs), "f");
457
- return tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f");
491
+ const map = (0, named_node_map_1.toNamedNodeMap)(attrs);
492
+ tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").set(origin, map);
493
+ return map;
458
494
  }
459
495
  /**
460
496
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -603,7 +639,19 @@ class MLElement extends parent_node_1.MLParentNode {
603
639
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-id%E2%91%A0
604
640
  */
605
641
  get id() {
606
- return this.getAttribute('id') || '';
642
+ var _a;
643
+ return (_a = this.getAttribute('id')) !== null && _a !== void 0 ? _a : '';
644
+ }
645
+ /**
646
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
647
+ *
648
+ * @deprecated
649
+ * @unsupported
650
+ * @implements DOM API: `Element`
651
+ * @see https://html.spec.whatwg.org/multipage/interaction.html#dom-inert
652
+ */
653
+ get inert() {
654
+ throw new unexpected_call_error_1.default('Not supported "inert" property');
607
655
  }
608
656
  /**
609
657
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -671,10 +719,14 @@ class MLElement extends parent_node_1.MLParentNode {
671
719
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-localname%E2%91%A0
672
720
  */
673
721
  get localName() {
674
- if (this.isForeignElement || this.isCustomElement) {
675
- return this._astToken.nodeName;
722
+ var _a;
723
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
724
+ return this.pretenderContext.as.localName;
725
+ }
726
+ if (this.isForeignElement || this.elementType !== 'html') {
727
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f");
676
728
  }
677
- return this._astToken.nodeName.toLowerCase();
729
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f").toLowerCase();
678
730
  }
679
731
  /**
680
732
  * The element immediately following the specified one in its parent's children list.
@@ -692,7 +744,11 @@ class MLElement extends parent_node_1.MLParentNode {
692
744
  * @see https://dom.spec.whatwg.org/#ref-for-element%E2%91%A2%E2%93%AA
693
745
  */
694
746
  get nodeName() {
695
- if (this.isForeignElement || this.isCustomElement) {
747
+ var _a;
748
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
749
+ return this.pretenderContext.as.nodeName;
750
+ }
751
+ if (this.isForeignElement || this.elementType !== 'html') {
696
752
  return this._astToken.nodeName;
697
753
  }
698
754
  return this._astToken.nodeName.toUpperCase();
@@ -823,6 +879,16 @@ class MLElement extends parent_node_1.MLParentNode {
823
879
  get onauxclick() {
824
880
  throw new unexpected_call_error_1.default('Not supported "onauxclick" property');
825
881
  }
882
+ /**
883
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
884
+ *
885
+ * @deprecated
886
+ * @unsupported
887
+ * @implements DOM API: `Element`
888
+ */
889
+ get onbeforeinput() {
890
+ throw new unexpected_call_error_1.default('Not supported "onbeforeinput" property');
891
+ }
826
892
  /**
827
893
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
828
894
  *
@@ -833,6 +899,16 @@ class MLElement extends parent_node_1.MLParentNode {
833
899
  get onblur() {
834
900
  throw new unexpected_call_error_1.default('Not supported "onblur" property');
835
901
  }
902
+ /**
903
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
904
+ *
905
+ * @deprecated
906
+ * @unsupported
907
+ * @implements DOM API: `Element`
908
+ */
909
+ get oncancel() {
910
+ throw new unexpected_call_error_1.default('Not supported "oncanplay" property');
911
+ }
836
912
  /**
837
913
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
838
914
  *
@@ -1714,7 +1790,10 @@ class MLElement extends parent_node_1.MLParentNode {
1714
1790
  return (0, child_node_methods_1.previousElementSibling)(this);
1715
1791
  }
1716
1792
  get raw() {
1717
- var _a;
1793
+ var _a, _b, _c;
1794
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
1795
+ return this.originRaw;
1796
+ }
1718
1797
  let fixed = this.originRaw;
1719
1798
  let gap = 0;
1720
1799
  if (this.nodeName !== this.fixedNodeName) {
@@ -1722,7 +1801,7 @@ class MLElement extends parent_node_1.MLParentNode {
1722
1801
  gap = gap + this.fixedNodeName.length - this.nodeName.length;
1723
1802
  }
1724
1803
  for (const attr of Array.from(this.attributes)) {
1725
- const startOffset = (((_a = attr.spacesBeforeName) === null || _a === void 0 ? void 0 : _a.startOffset) || attr.startOffset) - this.startOffset;
1804
+ const startOffset = ((_c = (_b = attr.spacesBeforeName) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : attr.startOffset) - this.startOffset;
1726
1805
  const fixedAttr = attr.toString();
1727
1806
  if (attr.originRaw !== fixedAttr) {
1728
1807
  fixed = (0, string_splice_1.stringSplice)(fixed, startOffset + gap, attr.originRaw.length, fixedAttr);
@@ -1737,6 +1816,26 @@ class MLElement extends parent_node_1.MLParentNode {
1737
1816
  get rawName() {
1738
1817
  return this._astToken.nodeName;
1739
1818
  }
1819
+ /**
1820
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1821
+ *
1822
+ * @unsupported
1823
+ * @implements DOM API: `Element`
1824
+ * @see https://w3c.github.io/aria/#ARIAMixin
1825
+ */
1826
+ get role() {
1827
+ throw new unexpected_call_error_1.default('Not supported "role" property');
1828
+ }
1829
+ /**
1830
+ * @implements `@markuplint/ml-core` API: `MLNode`
1831
+ */
1832
+ get rule() {
1833
+ var _a;
1834
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'origin') {
1835
+ return this.pretenderContext.origin.rule;
1836
+ }
1837
+ return super.rule;
1838
+ }
1740
1839
  /**
1741
1840
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1742
1841
  *
@@ -1792,7 +1891,8 @@ class MLElement extends parent_node_1.MLParentNode {
1792
1891
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-slot%E2%91%A0
1793
1892
  */
1794
1893
  get slot() {
1795
- return this.getAttribute('slot') || '';
1894
+ var _a;
1895
+ return (_a = this.getAttribute('slot')) !== null && _a !== void 0 ? _a : '';
1796
1896
  }
1797
1897
  /**
1798
1898
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -1841,11 +1941,15 @@ class MLElement extends parent_node_1.MLParentNode {
1841
1941
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-tagname%E2%91%A0
1842
1942
  */
1843
1943
  get tagName() {
1944
+ var _a;
1945
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
1946
+ return this.pretenderContext.as.nodeName;
1947
+ }
1844
1948
  return this.nodeName;
1845
1949
  }
1846
1950
  get textContent() {
1847
1951
  return Array.from(this.childNodes)
1848
- .map(child => child.textContent || '')
1952
+ .map(child => { var _a; return (_a = child.textContent) !== null && _a !== void 0 ? _a : ''; })
1849
1953
  .join('');
1850
1954
  }
1851
1955
  /**
@@ -1871,7 +1975,9 @@ class MLElement extends parent_node_1.MLParentNode {
1871
1975
  /**
1872
1976
  * @implements DOM API: `Element`
1873
1977
  */
1874
- after(...nodes) {
1978
+ after(
1979
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1980
+ ...nodes) {
1875
1981
  (0, child_node_methods_1.after)(this, ...nodes);
1876
1982
  }
1877
1983
  /**
@@ -1881,7 +1987,11 @@ class MLElement extends parent_node_1.MLParentNode {
1881
1987
  * @implements DOM API: `Element`
1882
1988
  * @see https://www.w3.org/TR/web-animations-1/#dom-animatable-animate
1883
1989
  */
1884
- animate(keyframes, options) {
1990
+ animate(
1991
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1992
+ keyframes,
1993
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1994
+ options) {
1885
1995
  throw new unexpected_call_error_1.default('Not supported "animate" method');
1886
1996
  }
1887
1997
  /**
@@ -1901,13 +2011,17 @@ class MLElement extends parent_node_1.MLParentNode {
1901
2011
  * @implements DOM API: `Element`
1902
2012
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-attachshadow%E2%91%A0
1903
2013
  */
1904
- attachShadow(init) {
2014
+ attachShadow(
2015
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2016
+ init) {
1905
2017
  throw new unexpected_call_error_1.default('Not supported "attachShadow" method');
1906
2018
  }
1907
2019
  /**
1908
2020
  * @implements DOM API: `Element`
1909
2021
  */
1910
- before(...nodes) {
2022
+ before(
2023
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2024
+ ...nodes) {
1911
2025
  (0, child_node_methods_1.before)(this, ...nodes);
1912
2026
  }
1913
2027
  /**
@@ -1920,6 +2034,18 @@ class MLElement extends parent_node_1.MLParentNode {
1920
2034
  blur() {
1921
2035
  throw new unexpected_call_error_1.default('Not supported "blur" method');
1922
2036
  }
2037
+ /**
2038
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
2039
+ *
2040
+ * @deprecated
2041
+ * @unsupported
2042
+ * @implements DOM API: `Element`
2043
+ */
2044
+ checkVisibility(
2045
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2046
+ options) {
2047
+ throw new unexpected_call_error_1.default('Not supported "checkVisibility" method');
2048
+ }
1923
2049
  /**
1924
2050
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1925
2051
  *
@@ -1954,14 +2080,16 @@ class MLElement extends parent_node_1.MLParentNode {
1954
2080
  * @unsupported
1955
2081
  * @implements DOM API: `Element`
1956
2082
  */
1957
- focus(options) {
2083
+ focus(
2084
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2085
+ options) {
1958
2086
  throw new unexpected_call_error_1.default('Not supported "focus" method');
1959
2087
  }
1960
2088
  /**
1961
2089
  * @implements `@markuplint/ml-core` API: `MLElement`
1962
2090
  */
1963
- getAccessibleName() {
1964
- return (0, accname_1.getAccname)(this);
2091
+ getAccessibleName(version) {
2092
+ return (0, accname_1.getAccname)(this, version);
1965
2093
  }
1966
2094
  /**
1967
2095
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -1970,7 +2098,9 @@ class MLElement extends parent_node_1.MLParentNode {
1970
2098
  * @implements DOM API: `Element`
1971
2099
  * @see https://www.w3.org/TR/web-animations-1/#dom-animatable-getanimations
1972
2100
  */
1973
- getAnimations(options) {
2101
+ getAnimations(
2102
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2103
+ options) {
1974
2104
  throw new unexpected_call_error_1.default('Not supported "getAnimations" method');
1975
2105
  }
1976
2106
  /**
@@ -1985,6 +2115,16 @@ class MLElement extends parent_node_1.MLParentNode {
1985
2115
  }
1986
2116
  return null;
1987
2117
  }
2118
+ /**
2119
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
2120
+ *
2121
+ * @unsupported
2122
+ * @implements DOM API: `Element`
2123
+ * @see https://dom.spec.whatwg.org/#dom-element-getattributenodens
2124
+ */
2125
+ getAttributeNS(namespace, localName) {
2126
+ throw new unexpected_call_error_1.default('Not supported "getAttributeNS" method');
2127
+ }
1988
2128
  /**
1989
2129
  * @implements DOM API: `Element`
1990
2130
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-getattributenames%E2%91%A0
@@ -1997,7 +2137,8 @@ class MLElement extends parent_node_1.MLParentNode {
1997
2137
  * @see https://dom.spec.whatwg.org/#dom-element-getattributenode
1998
2138
  */
1999
2139
  getAttributeNode(qualifiedName) {
2000
- return this.getAttributeToken(qualifiedName)[0] || null;
2140
+ var _a;
2141
+ return (_a = this.getAttributeToken(qualifiedName)[0]) !== null && _a !== void 0 ? _a : null;
2001
2142
  }
2002
2143
  /**
2003
2144
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2010,14 +2151,15 @@ class MLElement extends parent_node_1.MLParentNode {
2010
2151
  throw new unexpected_call_error_1.default('Not supported "getAttributeNodeNS" method');
2011
2152
  }
2012
2153
  /**
2013
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
2014
- *
2015
- * @unsupported
2016
- * @implements DOM API: `Element`
2017
- * @see https://dom.spec.whatwg.org/#dom-element-getattributenodens
2154
+ * @implements `@markuplint/ml-core` API: `MLElement`
2018
2155
  */
2019
- getAttributeNS(namespace, localName) {
2020
- throw new unexpected_call_error_1.default('Not supported "getAttributeNS" method');
2156
+ getAttributePretended(attrName) {
2157
+ for (const attr of Array.from(tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f"))) {
2158
+ if (attr.name.toLowerCase() === attrName.toLowerCase()) {
2159
+ return attr.value;
2160
+ }
2161
+ }
2162
+ return null;
2021
2163
  }
2022
2164
  /**
2023
2165
  * @implements `@markuplint/ml-core` API: `MLElement`
@@ -2036,7 +2178,8 @@ class MLElement extends parent_node_1.MLParentNode {
2036
2178
  * @implements `@markuplint/ml-core` API: `MLElement`
2037
2179
  */
2038
2180
  getAttributeTokens() {
2039
- return Object.freeze(tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f"));
2181
+ var _a;
2182
+ return Object.freeze(((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? tslib_1.__classPrivateFieldGet(this.pretenderContext.as, _MLElement_attributes, "f") : tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f"));
2040
2183
  }
2041
2184
  /**
2042
2185
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2144,7 +2287,7 @@ class MLElement extends parent_node_1.MLParentNode {
2144
2287
  * @see https://dom.spec.whatwg.org/#dom-element-hasattributes
2145
2288
  */
2146
2289
  hasAttributes() {
2147
- return !!this.attributes.length;
2290
+ return this.attributes.length > 0;
2148
2291
  }
2149
2292
  /**
2150
2293
  * @implements `@markuplint/ml-core` API: `MLElement`
@@ -2198,7 +2341,9 @@ class MLElement extends parent_node_1.MLParentNode {
2198
2341
  * @implements DOM API: `Element`
2199
2342
  * @see https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
2200
2343
  */
2201
- insertAdjacentElement(where, element) {
2344
+ insertAdjacentElement(where,
2345
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2346
+ element) {
2202
2347
  // TODO:
2203
2348
  throw new unexpected_call_error_1.default('Does not implement "insertAdjacentElement" method yet');
2204
2349
  }
@@ -2240,12 +2385,125 @@ class MLElement extends parent_node_1.MLParentNode {
2240
2385
  } while (el !== null && el.is(el.ELEMENT_NODE));
2241
2386
  return false;
2242
2387
  }
2388
+ /**
2389
+ * @implements `@markuplint/ml-core` API: `MLElement`
2390
+ */
2391
+ isEmpty() {
2392
+ var _a;
2393
+ for (const childNode of Array.from(this.childNodes)) {
2394
+ if (!(childNode.is(childNode.TEXT_NODE) && ((_a = childNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === '')) {
2395
+ return false;
2396
+ }
2397
+ }
2398
+ return true;
2399
+ }
2243
2400
  /**
2244
2401
  * @implements DOM API: `Element`
2245
2402
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
2246
2403
  */
2247
2404
  matches(selector) {
2248
- return !!(0, selector_1.createSelector)(selector, this.ownerMLDocument.specs).match(this);
2405
+ var _a;
2406
+ return ((0, selector_1.createSelector)(selector, this.ownerMLDocument.specs).match(
2407
+ // Prioritize the pretender
2408
+ ((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? this.pretenderContext.as : this) !== false);
2409
+ }
2410
+ /**
2411
+ * Pretenders Initialization
2412
+ */
2413
+ pretending(pretenders) {
2414
+ var _a;
2415
+ const pretenderConfig = pretenders === null || pretenders === void 0 ? void 0 : pretenders.find(option => this.matches(option.selector));
2416
+ if (!pretenderConfig) {
2417
+ return;
2418
+ }
2419
+ let nodeName;
2420
+ let namespace = 'html';
2421
+ const attributes = [];
2422
+ let aria;
2423
+ if (typeof pretenderConfig.as === 'string') {
2424
+ nodeName = pretenderConfig.as;
2425
+ }
2426
+ else {
2427
+ nodeName = pretenderConfig.as.element;
2428
+ namespace = (_a = pretenderConfig.as.namespace) !== null && _a !== void 0 ? _a : namespace;
2429
+ if (pretenderConfig.as.inheritAttrs) {
2430
+ attributes.push(...this._astToken.attributes);
2431
+ }
2432
+ if (pretenderConfig.as.attrs) {
2433
+ attributes.push(...pretenderConfig.as.attrs.map(({ name, value }, i) => {
2434
+ var _a;
2435
+ const _value = value != null
2436
+ ? typeof value === 'string'
2437
+ ? value
2438
+ : (_a = this.getAttribute(value.fromAttr)) !== null && _a !== void 0 ? _a : ''
2439
+ : '';
2440
+ return {
2441
+ ...this._astToken,
2442
+ uuid: `${this.uuid}_attr_${i}`,
2443
+ type: 'html-attr',
2444
+ nodeName: name,
2445
+ spacesBeforeName: {
2446
+ ...this._astToken,
2447
+ raw: '',
2448
+ },
2449
+ name: {
2450
+ ...this._astToken,
2451
+ raw: name,
2452
+ },
2453
+ spacesBeforeEqual: {
2454
+ ...this._astToken,
2455
+ raw: '',
2456
+ },
2457
+ equal: {
2458
+ ...this._astToken,
2459
+ raw: '',
2460
+ },
2461
+ spacesAfterEqual: {
2462
+ ...this._astToken,
2463
+ raw: '',
2464
+ },
2465
+ startQuote: {
2466
+ ...this._astToken,
2467
+ raw: '',
2468
+ },
2469
+ value: {
2470
+ ...this._astToken,
2471
+ raw: _value,
2472
+ },
2473
+ endQuote: {
2474
+ ...this._astToken,
2475
+ raw: '',
2476
+ },
2477
+ isDuplicatable: true,
2478
+ parentNode: null,
2479
+ nextNode: null,
2480
+ prevNode: null,
2481
+ isFragment: false,
2482
+ isGhost: false,
2483
+ };
2484
+ }));
2485
+ }
2486
+ aria = pretenderConfig.as.aria;
2487
+ }
2488
+ const as = new MLElement({
2489
+ ...this._astToken,
2490
+ uuid: this.uuid + '_pretender',
2491
+ raw: `<${nodeName}>`,
2492
+ nodeName,
2493
+ namespace,
2494
+ elementType: 'html',
2495
+ attributes,
2496
+ }, this.ownerMLDocument);
2497
+ as.resetChildren(this.childNodes);
2498
+ as.pretenderContext = {
2499
+ type: 'origin',
2500
+ origin: this,
2501
+ };
2502
+ this.pretenderContext = {
2503
+ type: 'pretender',
2504
+ as,
2505
+ aria,
2506
+ };
2249
2507
  }
2250
2508
  /**
2251
2509
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2278,25 +2536,29 @@ class MLElement extends parent_node_1.MLParentNode {
2278
2536
  *
2279
2537
  * @unsupported
2280
2538
  * @implements DOM API: `Element`
2281
- * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
2539
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
2282
2540
  */
2283
- removeAttributeNode(attr) {
2284
- throw new unexpected_call_error_1.default('Not supported "removeAttributeNode" method');
2541
+ removeAttributeNS(namespace, localName) {
2542
+ throw new unexpected_call_error_1.default('Not supported "removeAttributeNS" method');
2285
2543
  }
2286
2544
  /**
2287
2545
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2288
2546
  *
2289
2547
  * @unsupported
2290
2548
  * @implements DOM API: `Element`
2291
- * @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
2549
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
2292
2550
  */
2293
- removeAttributeNS(namespace, localName) {
2294
- throw new unexpected_call_error_1.default('Not supported "removeAttributeNS" method');
2551
+ removeAttributeNode(
2552
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2553
+ attr) {
2554
+ throw new unexpected_call_error_1.default('Not supported "removeAttributeNode" method');
2295
2555
  }
2296
2556
  /**
2297
2557
  * @implements DOM API: `Element`
2298
2558
  */
2299
- replaceWith(...nodes) {
2559
+ replaceWith(
2560
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2561
+ ...nodes) {
2300
2562
  (0, child_node_methods_1.replaceWith)(this, ...nodes);
2301
2563
  }
2302
2564
  /**
@@ -2306,7 +2568,9 @@ class MLElement extends parent_node_1.MLParentNode {
2306
2568
  * @implements DOM API: `Element`
2307
2569
  * @see https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
2308
2570
  */
2309
- requestFullscreen(options) {
2571
+ requestFullscreen(
2572
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2573
+ options) {
2310
2574
  throw new unexpected_call_error_1.default('Not supported "requestFullscreen" method');
2311
2575
  }
2312
2576
  /**
@@ -2346,7 +2610,9 @@ class MLElement extends parent_node_1.MLParentNode {
2346
2610
  * @implements DOM API: `Element`
2347
2611
  * @see https://www.w3.org/TR/cssom-view-1/#dom-element-scrollintoview
2348
2612
  */
2349
- scrollIntoView(arg) {
2613
+ scrollIntoView(
2614
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2615
+ arg) {
2350
2616
  throw new unexpected_call_error_1.default('Not supported "scrollIntoView" method');
2351
2617
  }
2352
2618
  /**
@@ -2374,30 +2640,34 @@ class MLElement extends parent_node_1.MLParentNode {
2374
2640
  *
2375
2641
  * @unsupported
2376
2642
  * @implements DOM API: `Element`
2377
- * @see https://dom.spec.whatwg.org/#dom-element-setattributenode
2643
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
2378
2644
  */
2379
- setAttributeNode(attr) {
2380
- throw new unexpected_call_error_1.default('Not supported "setAttributeNode" method');
2645
+ setAttributeNS(namespace, qualifiedName, value) {
2646
+ throw new unexpected_call_error_1.default('Not supported "setAttributeNS" method');
2381
2647
  }
2382
2648
  /**
2383
2649
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2384
2650
  *
2385
2651
  * @unsupported
2386
2652
  * @implements DOM API: `Element`
2387
- * @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
2653
+ * @see https://dom.spec.whatwg.org/#dom-element-setattributenode
2388
2654
  */
2389
- setAttributeNodeNS(attr) {
2390
- throw new unexpected_call_error_1.default('Not supported "setAttributeNodeNS" method');
2655
+ setAttributeNode(
2656
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2657
+ attr) {
2658
+ throw new unexpected_call_error_1.default('Not supported "setAttributeNode" method');
2391
2659
  }
2392
2660
  /**
2393
2661
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2394
2662
  *
2395
2663
  * @unsupported
2396
2664
  * @implements DOM API: `Element`
2397
- * @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
2665
+ * @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
2398
2666
  */
2399
- setAttributeNS(namespace, qualifiedName, value) {
2400
- throw new unexpected_call_error_1.default('Not supported "setAttributeNS" method');
2667
+ setAttributeNodeNS(
2668
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2669
+ attr) {
2670
+ throw new unexpected_call_error_1.default('Not supported "setAttributeNodeNS" method');
2401
2671
  }
2402
2672
  /**
2403
2673
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2409,16 +2679,6 @@ class MLElement extends parent_node_1.MLParentNode {
2409
2679
  setPointerCapture(pointerId) {
2410
2680
  throw new unexpected_call_error_1.default('Not supported "setPointerCapture" method');
2411
2681
  }
2412
- /**
2413
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
2414
- *
2415
- * @unsupported
2416
- * @implements DOM API: `Element`
2417
- * @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
2418
- */
2419
- toggleAttribute(qualifiedName, force) {
2420
- throw new unexpected_call_error_1.default('Not supported "toggleAttribute" method');
2421
- }
2422
2682
  /**
2423
2683
  * @implements `@markuplint/ml-core` API: `MLElement`
2424
2684
  */
@@ -2428,7 +2688,7 @@ class MLElement extends parent_node_1.MLParentNode {
2428
2688
  }
2429
2689
  const children = this.getChildElementsAndTextNodeWithoutWhitespaces();
2430
2690
  const attrs = this.attributes.map(attr => attr.toNormalizeString());
2431
- const attrString = attrs.length ? ' ' + attrs.join('') : '';
2691
+ const attrString = attrs.length > 0 ? ' ' + attrs.join('') : '';
2432
2692
  const startTag = `<${this.nodeName}${attrString}>`;
2433
2693
  const childNodes = children.map(node => {
2434
2694
  if (node.is(node.ELEMENT_NODE)) {
@@ -2447,6 +2707,16 @@ class MLElement extends parent_node_1.MLParentNode {
2447
2707
  toString() {
2448
2708
  return this.raw;
2449
2709
  }
2710
+ /**
2711
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
2712
+ *
2713
+ * @unsupported
2714
+ * @implements DOM API: `Element`
2715
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
2716
+ */
2717
+ toggleAttribute(qualifiedName, force) {
2718
+ throw new unexpected_call_error_1.default('Not supported "toggleAttribute" method');
2719
+ }
2450
2720
  /**
2451
2721
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2452
2722
  *
@@ -2459,4 +2729,4 @@ class MLElement extends parent_node_1.MLParentNode {
2459
2729
  }
2460
2730
  }
2461
2731
  exports.MLElement = MLElement;
2462
- _MLElement_attributes = new WeakMap(), _MLElement_fixedNodeName = new WeakMap(), _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache = new WeakMap(), _MLElement_normalizedAttrs = new WeakMap(), _MLElement_normalizedString = new WeakMap(), _MLElement_tagOpenChar = new WeakMap();
2732
+ _MLElement_attributes = new WeakMap(), _MLElement_fixedNodeName = new WeakMap(), _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache = new WeakMap(), _MLElement_localName = new WeakMap(), _MLElement_normalizedAttrs = new WeakMap(), _MLElement_normalizedString = new WeakMap(), _MLElement_tagOpenChar = new WeakMap();