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

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 (94) 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 +5 -1
  5. package/lib/ml-core.d.ts +3 -3
  6. package/lib/ml-core.js +13 -7
  7. package/lib/ml-dom/helper/accname.d.ts +2 -1
  8. package/lib/ml-dom/helper/accname.js +51 -2
  9. package/lib/ml-dom/helper/create-node.d.ts +2 -2
  10. package/lib/ml-dom/helper/create-node.js +1 -1
  11. package/lib/ml-dom/helper/debug.js +1 -1
  12. package/lib/ml-dom/helper/getIndent.d.ts +1 -1
  13. package/lib/ml-dom/helper/walkers.d.ts +2 -2
  14. package/lib/ml-dom/index.d.ts +1 -0
  15. package/lib/ml-dom/node/attr.d.ts +5 -5
  16. package/lib/ml-dom/node/attr.js +18 -12
  17. package/lib/ml-dom/node/block.d.ts +1 -1
  18. package/lib/ml-dom/node/character-data.d.ts +2 -2
  19. package/lib/ml-dom/node/child-node.d.ts +1 -1
  20. package/lib/ml-dom/node/document-fragment.d.ts +2 -2
  21. package/lib/ml-dom/node/document-type.d.ts +1 -1
  22. package/lib/ml-dom/node/document.d.ts +66 -21
  23. package/lib/ml-dom/node/document.js +72 -17
  24. package/lib/ml-dom/node/dom-token-list.d.ts +3 -3
  25. package/lib/ml-dom/node/dom-token-list.js +6 -6
  26. package/lib/ml-dom/node/element.d.ts +105 -30
  27. package/lib/ml-dom/node/element.js +279 -58
  28. package/lib/ml-dom/node/node-list.d.ts +1 -1
  29. package/lib/ml-dom/node/node-store.d.ts +3 -3
  30. package/lib/ml-dom/node/node.d.ts +21 -14
  31. package/lib/ml-dom/node/node.js +38 -29
  32. package/lib/ml-dom/node/parent-node.d.ts +2 -2
  33. package/lib/ml-dom/node/rule-mapper.d.ts +2 -2
  34. package/lib/ml-dom/node/types.d.ts +25 -15
  35. package/lib/ml-dom/token/token.d.ts +1 -1
  36. package/lib/ml-rule/ml-rule-context.d.ts +2 -1
  37. package/lib/ml-rule/ml-rule-context.js +19 -2
  38. package/lib/ml-rule/ml-rule.d.ts +5 -5
  39. package/lib/ml-rule/ml-rule.js +11 -12
  40. package/lib/ml-rule/types.d.ts +7 -7
  41. package/lib/plugin/types.d.ts +3 -3
  42. package/lib/test/index.d.ts +3 -2
  43. package/lib/test/index.js +5 -3
  44. package/lib/types.d.ts +5 -4
  45. package/package.json +14 -12
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/lib/ml-dom/document.d.ts +0 -94
  48. package/lib/ml-dom/document.js +0 -273
  49. package/lib/ml-dom/helper/index.d.ts +0 -4
  50. package/lib/ml-dom/helper/index.js +0 -12
  51. package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -52
  52. package/lib/ml-dom/helper/mapped-nodes.js +0 -2
  53. package/lib/ml-dom/helper/match-selector.d.ts +0 -20
  54. package/lib/ml-dom/helper/match-selector.js +0 -233
  55. package/lib/ml-dom/helper/node-store.d.ts +0 -12
  56. package/lib/ml-dom/helper/node-store.js +0 -28
  57. package/lib/ml-dom/helper/selector.d.ts +0 -11
  58. package/lib/ml-dom/helper/selector.js +0 -549
  59. package/lib/ml-dom/rule-mapper.d.ts +0 -16
  60. package/lib/ml-dom/rule-mapper.js +0 -57
  61. package/lib/ml-dom/tokens/abstract-element.d.ts +0 -54
  62. package/lib/ml-dom/tokens/abstract-element.js +0 -249
  63. package/lib/ml-dom/tokens/attribute.d.ts +0 -42
  64. package/lib/ml-dom/tokens/attribute.js +0 -85
  65. package/lib/ml-dom/tokens/comment.d.ts +0 -12
  66. package/lib/ml-dom/tokens/comment.js +0 -15
  67. package/lib/ml-dom/tokens/doctype.d.ts +0 -18
  68. package/lib/ml-dom/tokens/doctype.js +0 -32
  69. package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -27
  70. package/lib/ml-dom/tokens/element-close-tag.js +0 -45
  71. package/lib/ml-dom/tokens/element.d.ts +0 -26
  72. package/lib/ml-dom/tokens/element.js +0 -66
  73. package/lib/ml-dom/tokens/index.d.ts +0 -10
  74. package/lib/ml-dom/tokens/index.js +0 -26
  75. package/lib/ml-dom/tokens/node.d.ts +0 -46
  76. package/lib/ml-dom/tokens/node.js +0 -126
  77. package/lib/ml-dom/tokens/omitted-element.d.ts +0 -13
  78. package/lib/ml-dom/tokens/omitted-element.js +0 -12
  79. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
  80. package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
  81. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -14
  82. package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
  83. package/lib/ml-dom/tokens/text.d.ts +0 -19
  84. package/lib/ml-dom/tokens/text.js +0 -26
  85. package/lib/ml-dom/tokens/token.d.ts +0 -16
  86. package/lib/ml-dom/tokens/token.js +0 -55
  87. package/lib/ml-dom/types.d.ts +0 -49
  88. package/lib/ml-dom/types.js +0 -2
  89. package/lib/selector/is-pure-html-element.d.ts +0 -1
  90. package/lib/selector/is-pure-html-element.js +0 -7
  91. package/lib/selector/match-selector.d.ts +0 -14
  92. package/lib/selector/match-selector.js +0 -230
  93. package/lib/selector/selector.d.ts +0 -9
  94. package/lib/selector/selector.js +0 -561
@@ -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");
@@ -17,27 +18,25 @@ const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-ca
17
18
  const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
18
19
  class MLElement extends parent_node_1.MLParentNode {
19
20
  constructor(astNode, document) {
20
- var _a;
21
21
  super(astNode, document);
22
22
  _MLElement_attributes.set(this, void 0);
23
23
  _MLElement_fixedNodeName.set(this, void 0);
24
24
  _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache.set(this, null);
25
- _MLElement_normalizedAttrs.set(this, null);
25
+ _MLElement_localName.set(this, void 0);
26
+ _MLElement_normalizedAttrs.set(this, new Map());
26
27
  _MLElement_normalizedString.set(this, null);
28
+ this.pretenderContext = null;
27
29
  _MLElement_tagOpenChar.set(this, void 0);
28
30
  tslib_1.__classPrivateFieldSet(this, _MLElement_attributes, astNode.attributes.map(attr => new attr_1.MLAttr(attr, this)), "f");
29
31
  this.hasSpreadAttr = astNode.hasSpreadAttr;
30
32
  this.selfClosingSolidus = astNode.selfClosingSolidus ? new token_1.MLToken(astNode.selfClosingSolidus) : null;
31
33
  this.endSpace = astNode.endSpace ? new token_1.MLToken(astNode.endSpace) : null;
32
34
  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;
35
+ const ns = (0, ml_spec_1.resolveNamespace)(astNode.nodeName, astNode.namespace);
36
+ this.namespaceURI = ns.namespaceURI;
37
+ this.elementType = astNode.elementType;
38
+ tslib_1.__classPrivateFieldSet(this, _MLElement_localName, ns.localName, "f");
39
39
  this.isForeignElement = this.namespaceURI !== HTML_NAMESPACE;
40
- this.isCustomElement = astNode.isCustomElement;
41
40
  tslib_1.__classPrivateFieldSet(this, _MLElement_fixedNodeName, astNode.nodeName, "f");
42
41
  this.isOmitted = astNode.isGhost;
43
42
  tslib_1.__classPrivateFieldSet(this, _MLElement_tagOpenChar, astNode.tagOpenChar, "f");
@@ -122,6 +121,16 @@ class MLElement extends parent_node_1.MLParentNode {
122
121
  get ariaColIndex() {
123
122
  throw new unexpected_call_error_1.default('Not supported "ariaColIndex" property');
124
123
  }
124
+ /**
125
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
126
+ *
127
+ * @deprecated
128
+ * @unsupported
129
+ * @implements DOM API: `Element`
130
+ */
131
+ get ariaColIndexText() {
132
+ throw new unexpected_call_error_1.default('Not supported "ariaColIndexText" property');
133
+ }
125
134
  /**
126
135
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
127
136
  *
@@ -182,6 +191,16 @@ class MLElement extends parent_node_1.MLParentNode {
182
191
  get ariaHidden() {
183
192
  throw new unexpected_call_error_1.default('Not supported "ariaHidden" property');
184
193
  }
194
+ /**
195
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
196
+ *
197
+ * @deprecated
198
+ * @unsupported
199
+ * @implements DOM API: `Element`
200
+ */
201
+ get ariaInvalid() {
202
+ throw new unexpected_call_error_1.default('Not supported "ariaInvalid" property');
203
+ }
185
204
  /**
186
205
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
187
206
  *
@@ -342,6 +361,16 @@ class MLElement extends parent_node_1.MLParentNode {
342
361
  get ariaRowIndex() {
343
362
  throw new unexpected_call_error_1.default('Not supported "ariaRowIndex" property');
344
363
  }
364
+ /**
365
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
366
+ *
367
+ * @deprecated
368
+ * @unsupported
369
+ * @implements DOM API: `Element`
370
+ */
371
+ get ariaRowIndexText() {
372
+ throw new unexpected_call_error_1.default('Not supported "ariaRowIndexText" property');
373
+ }
345
374
  /**
346
375
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
347
376
  *
@@ -437,12 +466,14 @@ class MLElement extends parent_node_1.MLParentNode {
437
466
  * @see https://dom.spec.whatwg.org/#dom-element-attributes
438
467
  */
439
468
  get attributes() {
440
- if (tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f")) {
441
- return tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f");
469
+ var _a;
470
+ 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");
471
+ if (tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").has(origin)) {
472
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").get(origin);
442
473
  }
443
474
  const names = new Set();
444
475
  const attrs = [];
445
- for (const attr of tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f")) {
476
+ for (const attr of origin) {
446
477
  if (names.has(attr.name)) {
447
478
  /**
448
479
  * Skips a duplicated attribute
@@ -453,8 +484,9 @@ class MLElement extends parent_node_1.MLParentNode {
453
484
  }
454
485
  attrs.push(attr);
455
486
  }
456
- tslib_1.__classPrivateFieldSet(this, _MLElement_normalizedAttrs, (0, named_node_map_1.toNamedNodeMap)(attrs), "f");
457
- return tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f");
487
+ const map = (0, named_node_map_1.toNamedNodeMap)(attrs);
488
+ tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").set(origin, map);
489
+ return map;
458
490
  }
459
491
  /**
460
492
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -605,6 +637,17 @@ class MLElement extends parent_node_1.MLParentNode {
605
637
  get id() {
606
638
  return this.getAttribute('id') || '';
607
639
  }
640
+ /**
641
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
642
+ *
643
+ * @deprecated
644
+ * @unsupported
645
+ * @implements DOM API: `Element`
646
+ * @see https://html.spec.whatwg.org/multipage/interaction.html#dom-inert
647
+ */
648
+ get inert() {
649
+ throw new unexpected_call_error_1.default('Not supported "inert" property');
650
+ }
608
651
  /**
609
652
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
610
653
  *
@@ -671,10 +714,14 @@ class MLElement extends parent_node_1.MLParentNode {
671
714
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-localname%E2%91%A0
672
715
  */
673
716
  get localName() {
674
- if (this.isForeignElement || this.isCustomElement) {
675
- return this._astToken.nodeName;
717
+ var _a;
718
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
719
+ return this.pretenderContext.as.localName;
676
720
  }
677
- return this._astToken.nodeName.toLowerCase();
721
+ if (this.isForeignElement || this.elementType !== 'html') {
722
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f");
723
+ }
724
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f").toLowerCase();
678
725
  }
679
726
  /**
680
727
  * The element immediately following the specified one in its parent's children list.
@@ -692,7 +739,11 @@ class MLElement extends parent_node_1.MLParentNode {
692
739
  * @see https://dom.spec.whatwg.org/#ref-for-element%E2%91%A2%E2%93%AA
693
740
  */
694
741
  get nodeName() {
695
- if (this.isForeignElement || this.isCustomElement) {
742
+ var _a;
743
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
744
+ return this.pretenderContext.as.nodeName;
745
+ }
746
+ if (this.isForeignElement || this.elementType !== 'html') {
696
747
  return this._astToken.nodeName;
697
748
  }
698
749
  return this._astToken.nodeName.toUpperCase();
@@ -823,6 +874,16 @@ class MLElement extends parent_node_1.MLParentNode {
823
874
  get onauxclick() {
824
875
  throw new unexpected_call_error_1.default('Not supported "onauxclick" property');
825
876
  }
877
+ /**
878
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
879
+ *
880
+ * @deprecated
881
+ * @unsupported
882
+ * @implements DOM API: `Element`
883
+ */
884
+ get onbeforeinput() {
885
+ throw new unexpected_call_error_1.default('Not supported "onbeforeinput" property');
886
+ }
826
887
  /**
827
888
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
828
889
  *
@@ -833,6 +894,16 @@ class MLElement extends parent_node_1.MLParentNode {
833
894
  get onblur() {
834
895
  throw new unexpected_call_error_1.default('Not supported "onblur" property');
835
896
  }
897
+ /**
898
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
899
+ *
900
+ * @deprecated
901
+ * @unsupported
902
+ * @implements DOM API: `Element`
903
+ */
904
+ get oncancel() {
905
+ throw new unexpected_call_error_1.default('Not supported "oncanplay" property');
906
+ }
836
907
  /**
837
908
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
838
909
  *
@@ -1714,7 +1785,10 @@ class MLElement extends parent_node_1.MLParentNode {
1714
1785
  return (0, child_node_methods_1.previousElementSibling)(this);
1715
1786
  }
1716
1787
  get raw() {
1717
- var _a;
1788
+ var _a, _b;
1789
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
1790
+ return this.originRaw;
1791
+ }
1718
1792
  let fixed = this.originRaw;
1719
1793
  let gap = 0;
1720
1794
  if (this.nodeName !== this.fixedNodeName) {
@@ -1722,7 +1796,7 @@ class MLElement extends parent_node_1.MLParentNode {
1722
1796
  gap = gap + this.fixedNodeName.length - this.nodeName.length;
1723
1797
  }
1724
1798
  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;
1799
+ const startOffset = (((_b = attr.spacesBeforeName) === null || _b === void 0 ? void 0 : _b.startOffset) || attr.startOffset) - this.startOffset;
1726
1800
  const fixedAttr = attr.toString();
1727
1801
  if (attr.originRaw !== fixedAttr) {
1728
1802
  fixed = (0, string_splice_1.stringSplice)(fixed, startOffset + gap, attr.originRaw.length, fixedAttr);
@@ -1737,6 +1811,26 @@ class MLElement extends parent_node_1.MLParentNode {
1737
1811
  get rawName() {
1738
1812
  return this._astToken.nodeName;
1739
1813
  }
1814
+ /**
1815
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1816
+ *
1817
+ * @unsupported
1818
+ * @implements DOM API: `Element`
1819
+ * @see https://w3c.github.io/aria/#ARIAMixin
1820
+ */
1821
+ get role() {
1822
+ throw new unexpected_call_error_1.default('Not supported "role" property');
1823
+ }
1824
+ /**
1825
+ * @implements `@markuplint/ml-core` API: `MLNode`
1826
+ */
1827
+ get rule() {
1828
+ var _a;
1829
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'origin') {
1830
+ return this.pretenderContext.origin.rule;
1831
+ }
1832
+ return super.rule;
1833
+ }
1740
1834
  /**
1741
1835
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1742
1836
  *
@@ -1841,6 +1935,10 @@ class MLElement extends parent_node_1.MLParentNode {
1841
1935
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-tagname%E2%91%A0
1842
1936
  */
1843
1937
  get tagName() {
1938
+ var _a;
1939
+ if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
1940
+ return this.pretenderContext.as.nodeName;
1941
+ }
1844
1942
  return this.nodeName;
1845
1943
  }
1846
1944
  get textContent() {
@@ -1960,8 +2058,8 @@ class MLElement extends parent_node_1.MLParentNode {
1960
2058
  /**
1961
2059
  * @implements `@markuplint/ml-core` API: `MLElement`
1962
2060
  */
1963
- getAccessibleName() {
1964
- return (0, accname_1.getAccname)(this);
2061
+ getAccessibleName(version) {
2062
+ return (0, accname_1.getAccname)(this, version);
1965
2063
  }
1966
2064
  /**
1967
2065
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -1985,6 +2083,16 @@ class MLElement extends parent_node_1.MLParentNode {
1985
2083
  }
1986
2084
  return null;
1987
2085
  }
2086
+ /**
2087
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
2088
+ *
2089
+ * @unsupported
2090
+ * @implements DOM API: `Element`
2091
+ * @see https://dom.spec.whatwg.org/#dom-element-getattributenodens
2092
+ */
2093
+ getAttributeNS(namespace, localName) {
2094
+ throw new unexpected_call_error_1.default('Not supported "getAttributeNS" method');
2095
+ }
1988
2096
  /**
1989
2097
  * @implements DOM API: `Element`
1990
2098
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-getattributenames%E2%91%A0
@@ -2010,14 +2118,15 @@ class MLElement extends parent_node_1.MLParentNode {
2010
2118
  throw new unexpected_call_error_1.default('Not supported "getAttributeNodeNS" method');
2011
2119
  }
2012
2120
  /**
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
2121
+ * @implements `@markuplint/ml-core` API: `MLElement`
2018
2122
  */
2019
- getAttributeNS(namespace, localName) {
2020
- throw new unexpected_call_error_1.default('Not supported "getAttributeNS" method');
2123
+ getAttributePretended(attrName) {
2124
+ for (const attr of Array.from(tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f"))) {
2125
+ if (attr.name.toLowerCase() === attrName.toLowerCase()) {
2126
+ return attr.value;
2127
+ }
2128
+ }
2129
+ return null;
2021
2130
  }
2022
2131
  /**
2023
2132
  * @implements `@markuplint/ml-core` API: `MLElement`
@@ -2036,7 +2145,8 @@ class MLElement extends parent_node_1.MLParentNode {
2036
2145
  * @implements `@markuplint/ml-core` API: `MLElement`
2037
2146
  */
2038
2147
  getAttributeTokens() {
2039
- return Object.freeze(tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f"));
2148
+ var _a;
2149
+ 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
2150
  }
2041
2151
  /**
2042
2152
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2240,12 +2350,123 @@ class MLElement extends parent_node_1.MLParentNode {
2240
2350
  } while (el !== null && el.is(el.ELEMENT_NODE));
2241
2351
  return false;
2242
2352
  }
2353
+ /**
2354
+ * @implements `@markuplint/ml-core` API: `MLElement`
2355
+ */
2356
+ isEmpty() {
2357
+ var _a;
2358
+ for (const childNode of Array.from(this.childNodes)) {
2359
+ if (!(childNode.is(childNode.TEXT_NODE) && ((_a = childNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === '')) {
2360
+ return false;
2361
+ }
2362
+ }
2363
+ return true;
2364
+ }
2243
2365
  /**
2244
2366
  * @implements DOM API: `Element`
2245
2367
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
2246
2368
  */
2247
2369
  matches(selector) {
2248
- return !!(0, selector_1.createSelector)(selector, this.ownerMLDocument.specs).match(this);
2370
+ var _a;
2371
+ return !!(0, selector_1.createSelector)(selector, this.ownerMLDocument.specs).match(
2372
+ // Prioritize the pretender
2373
+ ((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? this.pretenderContext.as : this);
2374
+ }
2375
+ /**
2376
+ * Pretenders Initialization
2377
+ */
2378
+ pretending(pretenders) {
2379
+ const pretenderConfig = pretenders === null || pretenders === void 0 ? void 0 : pretenders.find(option => this.matches(option.selector));
2380
+ if (!pretenderConfig) {
2381
+ return;
2382
+ }
2383
+ let nodeName;
2384
+ let namespace = 'html';
2385
+ const attributes = [];
2386
+ let aria;
2387
+ if (typeof pretenderConfig.as === 'string') {
2388
+ nodeName = pretenderConfig.as;
2389
+ }
2390
+ else {
2391
+ nodeName = pretenderConfig.as.element;
2392
+ namespace = pretenderConfig.as.namespace || namespace;
2393
+ if (pretenderConfig.as.inheritAttrs) {
2394
+ attributes.push(...this._astToken.attributes);
2395
+ }
2396
+ if (pretenderConfig.as.attrs) {
2397
+ attributes.push(...pretenderConfig.as.attrs.map(({ name, value }, i) => {
2398
+ const _value = value
2399
+ ? typeof value === 'string'
2400
+ ? value
2401
+ : this.getAttribute(value.fromAttr) || ''
2402
+ : '';
2403
+ return {
2404
+ ...this._astToken,
2405
+ uuid: `${this.uuid}_attr_${i}`,
2406
+ type: 'html-attr',
2407
+ nodeName: name,
2408
+ spacesBeforeName: {
2409
+ ...this._astToken,
2410
+ raw: '',
2411
+ },
2412
+ name: {
2413
+ ...this._astToken,
2414
+ raw: name,
2415
+ },
2416
+ spacesBeforeEqual: {
2417
+ ...this._astToken,
2418
+ raw: '',
2419
+ },
2420
+ equal: {
2421
+ ...this._astToken,
2422
+ raw: '',
2423
+ },
2424
+ spacesAfterEqual: {
2425
+ ...this._astToken,
2426
+ raw: '',
2427
+ },
2428
+ startQuote: {
2429
+ ...this._astToken,
2430
+ raw: '',
2431
+ },
2432
+ value: {
2433
+ ...this._astToken,
2434
+ raw: _value,
2435
+ },
2436
+ endQuote: {
2437
+ ...this._astToken,
2438
+ raw: '',
2439
+ },
2440
+ isDuplicatable: true,
2441
+ parentNode: null,
2442
+ nextNode: null,
2443
+ prevNode: null,
2444
+ isFragment: false,
2445
+ isGhost: false,
2446
+ };
2447
+ }));
2448
+ }
2449
+ aria = pretenderConfig.as.aria;
2450
+ }
2451
+ const as = new MLElement({
2452
+ ...this._astToken,
2453
+ uuid: this.uuid + '_pretender',
2454
+ raw: `<${nodeName}>`,
2455
+ nodeName,
2456
+ namespace,
2457
+ elementType: 'html',
2458
+ attributes,
2459
+ }, this.ownerMLDocument);
2460
+ as.resetChildren(this.childNodes);
2461
+ as.pretenderContext = {
2462
+ type: 'origin',
2463
+ origin: this,
2464
+ };
2465
+ this.pretenderContext = {
2466
+ type: 'pretender',
2467
+ as,
2468
+ aria,
2469
+ };
2249
2470
  }
2250
2471
  /**
2251
2472
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2278,20 +2499,20 @@ class MLElement extends parent_node_1.MLParentNode {
2278
2499
  *
2279
2500
  * @unsupported
2280
2501
  * @implements DOM API: `Element`
2281
- * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
2502
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
2282
2503
  */
2283
- removeAttributeNode(attr) {
2284
- throw new unexpected_call_error_1.default('Not supported "removeAttributeNode" method');
2504
+ removeAttributeNS(namespace, localName) {
2505
+ throw new unexpected_call_error_1.default('Not supported "removeAttributeNS" method');
2285
2506
  }
2286
2507
  /**
2287
2508
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2288
2509
  *
2289
2510
  * @unsupported
2290
2511
  * @implements DOM API: `Element`
2291
- * @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
2512
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
2292
2513
  */
2293
- removeAttributeNS(namespace, localName) {
2294
- throw new unexpected_call_error_1.default('Not supported "removeAttributeNS" method');
2514
+ removeAttributeNode(attr) {
2515
+ throw new unexpected_call_error_1.default('Not supported "removeAttributeNode" method');
2295
2516
  }
2296
2517
  /**
2297
2518
  * @implements DOM API: `Element`
@@ -2374,30 +2595,30 @@ class MLElement extends parent_node_1.MLParentNode {
2374
2595
  *
2375
2596
  * @unsupported
2376
2597
  * @implements DOM API: `Element`
2377
- * @see https://dom.spec.whatwg.org/#dom-element-setattributenode
2598
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
2378
2599
  */
2379
- setAttributeNode(attr) {
2380
- throw new unexpected_call_error_1.default('Not supported "setAttributeNode" method');
2600
+ setAttributeNS(namespace, qualifiedName, value) {
2601
+ throw new unexpected_call_error_1.default('Not supported "setAttributeNS" method');
2381
2602
  }
2382
2603
  /**
2383
2604
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2384
2605
  *
2385
2606
  * @unsupported
2386
2607
  * @implements DOM API: `Element`
2387
- * @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
2608
+ * @see https://dom.spec.whatwg.org/#dom-element-setattributenode
2388
2609
  */
2389
- setAttributeNodeNS(attr) {
2390
- throw new unexpected_call_error_1.default('Not supported "setAttributeNodeNS" method');
2610
+ setAttributeNode(attr) {
2611
+ throw new unexpected_call_error_1.default('Not supported "setAttributeNode" method');
2391
2612
  }
2392
2613
  /**
2393
2614
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2394
2615
  *
2395
2616
  * @unsupported
2396
2617
  * @implements DOM API: `Element`
2397
- * @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
2618
+ * @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
2398
2619
  */
2399
- setAttributeNS(namespace, qualifiedName, value) {
2400
- throw new unexpected_call_error_1.default('Not supported "setAttributeNS" method');
2620
+ setAttributeNodeNS(attr) {
2621
+ throw new unexpected_call_error_1.default('Not supported "setAttributeNodeNS" method');
2401
2622
  }
2402
2623
  /**
2403
2624
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2409,16 +2630,6 @@ class MLElement extends parent_node_1.MLParentNode {
2409
2630
  setPointerCapture(pointerId) {
2410
2631
  throw new unexpected_call_error_1.default('Not supported "setPointerCapture" method');
2411
2632
  }
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
2633
  /**
2423
2634
  * @implements `@markuplint/ml-core` API: `MLElement`
2424
2635
  */
@@ -2447,6 +2658,16 @@ class MLElement extends parent_node_1.MLParentNode {
2447
2658
  toString() {
2448
2659
  return this.raw;
2449
2660
  }
2661
+ /**
2662
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
2663
+ *
2664
+ * @unsupported
2665
+ * @implements DOM API: `Element`
2666
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
2667
+ */
2668
+ toggleAttribute(qualifiedName, force) {
2669
+ throw new unexpected_call_error_1.default('Not supported "toggleAttribute" method');
2670
+ }
2450
2671
  /**
2451
2672
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
2452
2673
  *
@@ -2459,4 +2680,4 @@ class MLElement extends parent_node_1.MLParentNode {
2459
2680
  }
2460
2681
  }
2461
2682
  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();
2683
+ _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();
@@ -1,6 +1,6 @@
1
1
  import type { MLChildNode } from './child-node';
2
2
  import type { MLElement } from './element';
3
3
  import type { RuleConfigValue } from '@markuplint/ml-config';
4
- export declare function toNodeList<T extends RuleConfigValue, O extends Object | null, N extends MLChildNode<T, O>>(nodes: ReadonlyArray<N>): NodeListOf<N>;
4
+ export declare function toNodeList<T extends RuleConfigValue, O, N extends MLChildNode<T, O>>(nodes: ReadonlyArray<N>): NodeListOf<N>;
5
5
  export declare function toHTMLCollection<T extends RuleConfigValue, O = null>(nodes: ReadonlyArray<MLElement<T, O>>): HTMLCollectionOf<MLElement<T, O>>;
6
6
  export declare function nodeListToHTMLCollection<T extends RuleConfigValue, O = null>(nodeList: NodeListOf<MLChildNode<T, O>>): HTMLCollectionOf<MLElement<T, O>>;
@@ -1,11 +1,11 @@
1
1
  import type { MLNode } from './node';
2
2
  import type { MappedNode } from './types';
3
- import type { MLASTAbstructNode } from '@markuplint/ml-ast';
3
+ import type { MLASTAbstractNode } from '@markuplint/ml-ast';
4
4
  import type { RuleConfigValue } from '@markuplint/ml-config';
5
5
  declare class NodeStore {
6
6
  #private;
7
- getNode<N extends MLASTAbstructNode, T extends RuleConfigValue, O = null>(astNode: N): MappedNode<N, T, O>;
8
- setNode<A extends MLASTAbstructNode, T extends RuleConfigValue, O = null>(astNode: A, node: MLNode<T, O, A>): void;
7
+ getNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: N): MappedNode<N, T, O>;
8
+ setNode<A extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: A, node: MLNode<T, O, A>): void;
9
9
  }
10
10
  /**
11
11
  * `NodeStore` Singleton
@@ -5,10 +5,10 @@ import type { MLDocument } from './document';
5
5
  import type { MLDocumentFragment } from './document-fragment';
6
6
  import type { MLElement } from './element';
7
7
  import type { MarkuplintPreprocessorBlockType, NodeType, NodeTypeOf } from './types';
8
- import type { MLASTAbstructNode } from '@markuplint/ml-ast';
8
+ import type { MLASTAbstractNode } from '@markuplint/ml-ast';
9
9
  import type { AnyRule, RuleConfigValue } from '@markuplint/ml-config';
10
10
  import { MLToken } from '../token/token';
11
- export declare abstract class MLNode<T extends RuleConfigValue, O = null, A extends MLASTAbstructNode = MLASTAbstructNode> extends MLToken<A> implements Node {
11
+ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLToken<A> implements Node {
12
12
  #private;
13
13
  /**
14
14
  * @implements DOM API: `Node`
@@ -102,13 +102,17 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
102
102
  * @see https://dom.spec.whatwg.org/#interface-node
103
103
  */
104
104
  readonly PROCESSING_INSTRUCTION_NODE = 7;
105
- readonly rules: Record<string, AnyRule>;
106
105
  /**
107
106
  * @implements DOM API: `Node`
108
107
  * @see https://dom.spec.whatwg.org/#interface-node
109
108
  */
110
109
  readonly TEXT_NODE = 3;
110
+ /**
111
+ *
112
+ */
113
+ readonly rules: Record<string, AnyRule>;
111
114
  protected _astToken: A;
115
+ constructor(astNode: A, document: MLDocument<T, O>);
112
116
  /**
113
117
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
114
118
  *
@@ -250,14 +254,6 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
250
254
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-parentnode%E2%91%A0
251
255
  */
252
256
  get parentNode(): MLDocument<any, any> | MLDocumentFragment<any, any> | MLElement<T, O> | null;
253
- /**
254
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
255
- *
256
- * @unsupported
257
- * @implements DOM API: `Node`
258
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
259
- */
260
- get previousSibling(): ChildNode | null;
261
257
  /**
262
258
  * @implements `@markuplint/ml-core` API: `MLNode`
263
259
  */
@@ -266,12 +262,20 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
266
262
  * @implements `@markuplint/ml-core` API: `MLNode`
267
263
  */
268
264
  get prevToken(): MLNode<T, O> | null;
265
+ /**
266
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
267
+ *
268
+ * @unsupported
269
+ * @implements DOM API: `Node`
270
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
271
+ */
272
+ get previousSibling(): ChildNode | null;
269
273
  /**
270
274
  * @implements `@markuplint/ml-core` API: `MLNode`
271
275
  */
272
276
  get rule(): RuleInfo<T, O>;
273
277
  /**
274
- * Returns a syntaxical parent node
278
+ * Returns a syntactical parent node
275
279
  *
276
280
  * ## HTML:
277
281
  *
@@ -308,7 +312,7 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
308
312
  *
309
313
  * @implements `@markuplint/ml-core` API: `MLNode`
310
314
  */
311
- get syntaxicalParentNode(): MLDocument<any, any> | MLDocumentFragment<any, any> | MLElement<T, O> | MLBlock<T, O> | null;
315
+ get syntacticalParentNode(): MLDocument<any, any> | MLDocumentFragment<any, any> | MLElement<T, O> | MLBlock<T, O> | null;
312
316
  /**
313
317
  * Return the text content.
314
318
  *
@@ -319,7 +323,6 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
319
323
  * @see https://dom.spec.whatwg.org/#dom-node-textcontent
320
324
  */
321
325
  get textContent(): string | null;
322
- constructor(astNode: A, document: MLDocument<T, O>);
323
326
  /**
324
327
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
325
328
  *
@@ -472,4 +475,8 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
472
475
  * @see https://dom.spec.whatwg.org/#dom-node-replacechild
473
476
  */
474
477
  replaceChild<T extends Node>(node: Node, child: T): T;
478
+ /**
479
+ * @implements `@markuplint/ml-core` API: `MLNode`
480
+ */
481
+ resetChildren(childNodes?: NodeListOf<MLChildNode<T, O>>): void;
475
482
  }