@markuplint/ml-core 3.15.0 → 4.0.0-alpha.10

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 (105) hide show
  1. package/LICENSE +1 -1
  2. package/lib/configs.browser.js +11 -11
  3. package/lib/convert-ruleset.d.ts +1 -1
  4. package/lib/convert-ruleset.js +3 -8
  5. package/lib/debug.js +9 -14
  6. package/lib/index.d.ts +13 -23
  7. package/lib/index.js +12 -29
  8. package/lib/ml-core.d.ts +5 -5
  9. package/lib/ml-core.js +94 -76
  10. package/lib/ml-dom/helper/accname.d.ts +1 -1
  11. package/lib/ml-dom/helper/accname.js +12 -19
  12. package/lib/ml-dom/helper/create-node.d.ts +4 -8
  13. package/lib/ml-dom/helper/create-node.js +38 -17
  14. package/lib/ml-dom/helper/debug.d.ts +1 -1
  15. package/lib/ml-dom/helper/debug.js +13 -22
  16. package/lib/ml-dom/helper/get-indent.d.ts +18 -0
  17. package/lib/ml-dom/helper/get-indent.js +112 -0
  18. package/lib/ml-dom/helper/walkers.d.ts +5 -15
  19. package/lib/ml-dom/helper/walkers.js +3 -8
  20. package/lib/ml-dom/index.d.ts +9 -9
  21. package/lib/ml-dom/index.js +1 -5
  22. package/lib/ml-dom/manipulations/child-node-methods.d.ts +7 -20
  23. package/lib/ml-dom/manipulations/child-node-methods.js +13 -25
  24. package/lib/ml-dom/manipulations/get-children.d.ts +3 -5
  25. package/lib/ml-dom/manipulations/get-children.js +3 -7
  26. package/lib/ml-dom/node/attr.d.ts +113 -98
  27. package/lib/ml-dom/node/attr.js +93 -50
  28. package/lib/ml-dom/node/block.d.ts +35 -39
  29. package/lib/ml-dom/node/block.js +8 -14
  30. package/lib/ml-dom/node/character-data.d.ts +55 -62
  31. package/lib/ml-dom/node/character-data.js +11 -16
  32. package/lib/ml-dom/node/child-node.d.ts +8 -15
  33. package/lib/ml-dom/node/child-node.js +1 -5
  34. package/lib/ml-dom/node/comment.d.ts +14 -17
  35. package/lib/ml-dom/node/comment.js +2 -6
  36. package/lib/ml-dom/node/document-fragment.d.ts +22 -25
  37. package/lib/ml-dom/node/document-fragment.js +4 -9
  38. package/lib/ml-dom/node/document-type.d.ts +35 -38
  39. package/lib/ml-dom/node/document-type.js +8 -14
  40. package/lib/ml-dom/node/document.d.ts +1598 -1614
  41. package/lib/ml-dom/node/document.js +330 -275
  42. package/lib/ml-dom/node/dom-token-list.d.ts +27 -27
  43. package/lib/ml-dom/node/dom-token-list.js +36 -32
  44. package/lib/ml-dom/node/element-close-tag.d.ts +20 -0
  45. package/lib/ml-dom/node/element-close-tag.js +39 -0
  46. package/lib/ml-dom/node/element.d.ts +1957 -1951
  47. package/lib/ml-dom/node/element.js +364 -348
  48. package/lib/ml-dom/node/named-node-map.d.ts +40 -45
  49. package/lib/ml-dom/node/named-node-map.js +10 -18
  50. package/lib/ml-dom/node/node-list.d.ts +5 -11
  51. package/lib/ml-dom/node/node-list.js +8 -16
  52. package/lib/ml-dom/node/node-store.d.ts +6 -11
  53. package/lib/ml-dom/node/node-store.js +14 -13
  54. package/lib/ml-dom/node/node.d.ts +480 -500
  55. package/lib/ml-dom/node/node.js +83 -73
  56. package/lib/ml-dom/node/parent-node.d.ts +60 -69
  57. package/lib/ml-dom/node/parent-node.js +32 -29
  58. package/lib/ml-dom/node/rule-mapper.d.ts +9 -9
  59. package/lib/ml-dom/node/rule-mapper.js +26 -21
  60. package/lib/ml-dom/node/text.d.ts +48 -51
  61. package/lib/ml-dom/node/text.js +8 -13
  62. package/lib/ml-dom/node/types.d.ts +42 -90
  63. package/lib/ml-dom/node/types.js +1 -2
  64. package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -1
  65. package/lib/ml-dom/node/unexpected-call-error.js +1 -4
  66. package/lib/ml-dom/token/token.d.ts +45 -45
  67. package/lib/ml-dom/token/token.js +32 -26
  68. package/lib/ml-rule/create-rule.d.ts +2 -4
  69. package/lib/ml-rule/create-rule.js +1 -5
  70. package/lib/ml-rule/create-test-rule.d.ts +5 -7
  71. package/lib/ml-rule/create-test-rule.js +3 -7
  72. package/lib/ml-rule/index.d.ts +3 -3
  73. package/lib/ml-rule/index.js +3 -6
  74. package/lib/ml-rule/ml-rule-context.d.ts +49 -57
  75. package/lib/ml-rule/ml-rule-context.js +11 -11
  76. package/lib/ml-rule/ml-rule.d.ts +26 -36
  77. package/lib/ml-rule/ml-rule.js +34 -31
  78. package/lib/ml-rule/types.d.ts +18 -33
  79. package/lib/ml-rule/types.js +1 -2
  80. package/lib/plugin/index.d.ts +2 -2
  81. package/lib/plugin/index.js +2 -5
  82. package/lib/plugin/plugin.d.ts +2 -4
  83. package/lib/plugin/plugin.js +1 -5
  84. package/lib/plugin/types.d.ts +6 -6
  85. package/lib/plugin/types.js +1 -2
  86. package/lib/ruleset/index.d.ts +5 -5
  87. package/lib/ruleset/index.js +4 -8
  88. package/lib/test/index.d.ts +11 -21
  89. package/lib/test/index.js +18 -24
  90. package/lib/types.d.ts +11 -11
  91. package/lib/types.js +1 -2
  92. package/lib/utils/get-location-from-chars.d.ts +4 -9
  93. package/lib/utils/get-location-from-chars.js +4 -8
  94. package/lib/utils/index.d.ts +1 -1
  95. package/lib/utils/index.js +1 -5
  96. package/lib/utils/string-splice.js +1 -5
  97. package/package.json +19 -15
  98. package/lib/configs.d.ts +0 -2
  99. package/lib/configs.js +0 -34
  100. package/lib/ml-dom/helper/getIndent.d.ts +0 -18
  101. package/lib/ml-dom/helper/getIndent.js +0 -106
  102. package/test/ml-dom/helper/accname.spec.js +0 -85
  103. package/test/ml-dom/helper/create-node.spec.js +0 -18
  104. package/test/ml-dom/index.spec.js +0 -680
  105. package/test/ml-dom/ml-rule/create-rule.spec.js +0 -108
@@ -1,14 +1,21 @@
1
- "use strict";
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
2
12
  var _MLNode_childNodes, _MLNode_ownerDocument, _MLNode_prevToken;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.MLNode = void 0;
5
- const tslib_1 = require("tslib");
6
- const token_1 = require("../token/token");
7
- const child_node_1 = require("./child-node");
8
- const node_list_1 = require("./node-list");
9
- const node_store_1 = require("./node-store");
10
- const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
11
- class MLNode extends token_1.MLToken {
13
+ import { MLToken } from '../token/token.js';
14
+ import { isChildNode } from './child-node.js';
15
+ import { toNodeList } from './node-list.js';
16
+ import { nodeStore } from './node-store.js';
17
+ import { UnexpectedCallError } from './unexpected-call-error.js';
18
+ export class MLNode extends MLToken {
12
19
  constructor(astNode,
13
20
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
14
21
  document) {
@@ -47,7 +54,7 @@ class MLNode extends token_1.MLToken {
47
54
  * @implements DOM API: `Node`
48
55
  * @see https://dom.spec.whatwg.org/#dom-node-document_position_contains
49
56
  */
50
- this.DOCUMENT_POSITION_CONTAINS = 8;
57
+ this.DOCUMENT_POSITION_CONTAINS = 0b1000;
51
58
  /**
52
59
  * @implements DOM API: `Node`
53
60
  * @see https://dom.spec.whatwg.org/#dom-node-document_position_disconnected
@@ -130,8 +137,8 @@ class MLNode extends token_1.MLToken {
130
137
  */
131
138
  this.rules = {};
132
139
  this._astToken = astNode;
133
- tslib_1.__classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
134
- node_store_1.nodeStore.setNode(astNode, this);
140
+ __classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
141
+ nodeStore.setNode(astNode, this);
135
142
  }
136
143
  /**
137
144
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -141,7 +148,7 @@ class MLNode extends token_1.MLToken {
141
148
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-baseuri%E2%91%A0
142
149
  */
143
150
  get baseURI() {
144
- throw new unexpected_call_error_1.default('Not supported "baseURI" property');
151
+ throw new UnexpectedCallError('Not supported "baseURI" property');
145
152
  }
146
153
  /**
147
154
  * The list of child nodes that contains `Element`, `Text`, and `Comment`.
@@ -151,36 +158,41 @@ class MLNode extends token_1.MLToken {
151
158
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-childnodes%E2%91%A0
152
159
  */
153
160
  get childNodes() {
154
- var _a;
155
- if (tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f") != null) {
156
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
161
+ if (__classPrivateFieldGet(this, _MLNode_childNodes, "f") != null) {
162
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
157
163
  }
158
164
  if (this.is(this.DOCUMENT_NODE)) {
159
165
  const childNodes = [];
160
166
  for (const node of this.nodeList) {
161
- if ((0, child_node_1.isChildNode)(node) && (node.parentNode === this || node.parentNode === null)) {
167
+ if (isChildNode(node) && (node.parentNode === this || node.parentNode === null)) {
162
168
  childNodes.push(node);
163
169
  }
164
170
  }
165
171
  // Cache
166
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)(childNodes), "f");
167
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
172
+ __classPrivateFieldSet(this, _MLNode_childNodes, toNodeList(childNodes), "f");
173
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
168
174
  }
169
175
  if (this.is(this.DOCUMENT_FRAGMENT_NODE) ||
170
176
  this.is(this.ELEMENT_NODE) ||
171
177
  this.is(this.MARKUPLINT_PREPROCESSOR_BLOCK)) {
178
+ const astChildren =
172
179
  // @ts-ignore
173
- const astChildren = (_a = this._astToken.childNodes) !== null && _a !== void 0 ? _a : [];
180
+ this._astToken?.childNodes?.filter(node => {
181
+ if (node.type === 'endtag' || node.type === 'invalid') {
182
+ return null;
183
+ }
184
+ return node;
185
+ }) ?? [];
174
186
  const childNodes = astChildren
175
- .map(node => node_store_1.nodeStore.getNode(node))
176
- .filter((node) => (0, child_node_1.isChildNode)(node));
187
+ .map(node => nodeStore.getNode(node))
188
+ .filter(node => isChildNode(node));
177
189
  // Cache
178
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)(childNodes), "f");
179
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
190
+ __classPrivateFieldSet(this, _MLNode_childNodes, toNodeList(childNodes), "f");
191
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
180
192
  }
181
193
  // Cache
182
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)([]), "f");
183
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
194
+ __classPrivateFieldSet(this, _MLNode_childNodes, toNodeList([]), "f");
195
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
184
196
  }
185
197
  /**
186
198
  * The first node that may be `Element`, `Text`, and `CommentNode`.
@@ -190,8 +202,7 @@ class MLNode extends token_1.MLToken {
190
202
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-firstchild%E2%91%A0
191
203
  */
192
204
  get firstChild() {
193
- var _a;
194
- return (_a = this.childNodes[0]) !== null && _a !== void 0 ? _a : null;
205
+ return this.childNodes[0] ?? null;
195
206
  }
196
207
  /**
197
208
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -201,7 +212,7 @@ class MLNode extends token_1.MLToken {
201
212
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-isconnected%E2%91%A0
202
213
  */
203
214
  get isConnected() {
204
- throw new unexpected_call_error_1.default('Not supported "isConnected" property');
215
+ throw new UnexpectedCallError('Not supported "isConnected" property');
205
216
  }
206
217
  /**
207
218
  * The last node that may be `Element`, `Text`, and `CommentNode`.
@@ -211,17 +222,16 @@ class MLNode extends token_1.MLToken {
211
222
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-lastchild%E2%91%A0
212
223
  */
213
224
  get lastChild() {
214
- var _a;
215
- return (_a = this.childNodes[this.childNodes.length - 1]) !== null && _a !== void 0 ? _a : null;
225
+ // eslint-disable-next-line unicorn/prefer-at
226
+ return this.childNodes[this.childNodes.length - 1] ?? null;
216
227
  }
217
228
  /**
218
229
  * @implements `@markuplint/ml-core` API: `MLNode`
219
230
  */
220
231
  get nextNode() {
221
- if (!this._astToken.nextNode) {
222
- return null;
223
- }
224
- return node_store_1.nodeStore.getNode(this._astToken.nextNode);
232
+ const siblings = [...(this.syntacticalParentNode?.childNodes ?? __classPrivateFieldGet(this, _MLNode_ownerDocument, "f").nodeList)];
233
+ const index = siblings.findIndex(node => node.uuid === this.uuid);
234
+ return siblings[index + 1] ?? null;
225
235
  }
226
236
  /**
227
237
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -231,7 +241,7 @@ class MLNode extends token_1.MLToken {
231
241
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-nextsibling%E2%91%A0
232
242
  */
233
243
  get nextSibling() {
234
- throw new unexpected_call_error_1.default('Not supported "nextSibling" property');
244
+ throw new UnexpectedCallError('Not supported "nextSibling" property');
235
245
  }
236
246
  /**
237
247
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -272,10 +282,10 @@ class MLNode extends token_1.MLToken {
272
282
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument%E2%91%A0
273
283
  */
274
284
  get ownerDocument() {
275
- return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
285
+ return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
276
286
  }
277
287
  get ownerMLDocument() {
278
- return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
288
+ return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
279
289
  }
280
290
  /**
281
291
  * The parent element.
@@ -363,18 +373,16 @@ class MLNode extends token_1.MLToken {
363
373
  * @implements `@markuplint/ml-core` API: `MLNode`
364
374
  */
365
375
  get prevNode() {
366
- if (!this._astToken.prevNode) {
367
- return null;
368
- }
369
- return node_store_1.nodeStore.getNode(this._astToken.prevNode);
376
+ const siblings = [...(this.syntacticalParentNode?.childNodes ?? __classPrivateFieldGet(this, _MLNode_ownerDocument, "f").nodeList)];
377
+ const index = siblings.findIndex(node => node.uuid === this.uuid);
378
+ return siblings[index - 1] ?? null;
370
379
  }
371
380
  /**
372
381
  * @implements `@markuplint/ml-core` API: `MLNode`
373
382
  */
374
383
  get prevToken() {
375
- var _a, _b;
376
- if (tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f") !== undefined) {
377
- return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
384
+ if (__classPrivateFieldGet(this, _MLNode_prevToken, "f") !== undefined) {
385
+ return __classPrivateFieldGet(this, _MLNode_prevToken, "f");
378
386
  }
379
387
  let index = -1;
380
388
  for (let i = 0; i < this.ownerMLDocument.nodeList.length; i++) {
@@ -391,11 +399,11 @@ class MLNode extends token_1.MLToken {
391
399
  }
392
400
  }
393
401
  if (index === -1) {
394
- tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
395
- return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
402
+ __classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
403
+ return __classPrivateFieldGet(this, _MLNode_prevToken, "f");
396
404
  }
397
- tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, (_a = this.ownerMLDocument.nodeList[index - 1]) !== null && _a !== void 0 ? _a : null, "f");
398
- return (_b = tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f")) !== null && _b !== void 0 ? _b : null;
405
+ __classPrivateFieldSet(this, _MLNode_prevToken, this.ownerMLDocument.nodeList[index - 1] ?? null, "f");
406
+ return __classPrivateFieldGet(this, _MLNode_prevToken, "f") ?? null;
399
407
  }
400
408
  /**
401
409
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -405,7 +413,7 @@ class MLNode extends token_1.MLToken {
405
413
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
406
414
  */
407
415
  get previousSibling() {
408
- throw new unexpected_call_error_1.default('Not supported "previousSibling" property');
416
+ throw new UnexpectedCallError('Not supported "previousSibling" property');
409
417
  }
410
418
  /**
411
419
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -462,10 +470,13 @@ class MLNode extends token_1.MLToken {
462
470
  * @implements `@markuplint/ml-core` API: `MLNode`
463
471
  */
464
472
  get syntacticalParentNode() {
473
+ if (this._astToken.type === 'attr' || this._astToken.type === 'spread') {
474
+ return null;
475
+ }
465
476
  if (!this._astToken.parentNode) {
466
477
  return this.ownerMLDocument;
467
478
  }
468
- return node_store_1.nodeStore.getNode(this._astToken.parentNode);
479
+ return nodeStore.getNode(this._astToken.parentNode);
469
480
  }
470
481
  /**
471
482
  * Return the text content.
@@ -489,7 +500,7 @@ class MLNode extends token_1.MLToken {
489
500
  addEventListener(type,
490
501
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
491
502
  callback, options = {}) {
492
- throw new unexpected_call_error_1.default('Not supported "addEventListener" method');
503
+ throw new UnexpectedCallError('Not supported "addEventListener" method');
493
504
  }
494
505
  /**
495
506
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -499,7 +510,7 @@ class MLNode extends token_1.MLToken {
499
510
  * @see https://dom.spec.whatwg.org/#dom-node-appendchild
500
511
  */
501
512
  appendChild(node) {
502
- throw new unexpected_call_error_1.default('Not supported "appendChild" method');
513
+ throw new UnexpectedCallError('Not supported "appendChild" method');
503
514
  }
504
515
  /**
505
516
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -509,7 +520,7 @@ class MLNode extends token_1.MLToken {
509
520
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-clonenode%E2%91%A0
510
521
  */
511
522
  cloneNode(deep) {
512
- throw new unexpected_call_error_1.default('Not supported "appendChild" method');
523
+ throw new UnexpectedCallError('Not supported "appendChild" method');
513
524
  }
514
525
  /**
515
526
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -521,7 +532,7 @@ class MLNode extends token_1.MLToken {
521
532
  compareDocumentPosition(
522
533
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
523
534
  other) {
524
- throw new unexpected_call_error_1.default('Not supported "compareDocumentPosition" method');
535
+ throw new UnexpectedCallError('Not supported "compareDocumentPosition" method');
525
536
  }
526
537
  /**
527
538
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -533,7 +544,7 @@ class MLNode extends token_1.MLToken {
533
544
  contains(
534
545
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
535
546
  other) {
536
- throw new unexpected_call_error_1.default('Not supported "contains" method');
547
+ throw new UnexpectedCallError('Not supported "contains" method');
537
548
  }
538
549
  /**
539
550
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -545,7 +556,7 @@ class MLNode extends token_1.MLToken {
545
556
  dispatchEvent(
546
557
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
547
558
  event) {
548
- throw new unexpected_call_error_1.default('Not supported "dispatchEvent" method');
559
+ throw new UnexpectedCallError('Not supported "dispatchEvent" method');
549
560
  }
550
561
  /**
551
562
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -558,10 +569,10 @@ class MLNode extends token_1.MLToken {
558
569
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
559
570
  options) {
560
571
  if (options) {
561
- throw new unexpected_call_error_1.default('Not supported options');
572
+ throw new UnexpectedCallError('Not supported options');
562
573
  }
563
574
  // The original DOM API returns a document fragment if the element is a fragment.
564
- return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
575
+ return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
565
576
  }
566
577
  /**
567
578
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -571,7 +582,7 @@ class MLNode extends token_1.MLToken {
571
582
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-haschildnodes%E2%91%A0
572
583
  */
573
584
  hasChildNodes() {
574
- throw new unexpected_call_error_1.default('Not supported "hasChildNodes" method');
585
+ throw new UnexpectedCallError('Not supported "hasChildNodes" method');
575
586
  }
576
587
  /**
577
588
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -583,7 +594,7 @@ class MLNode extends token_1.MLToken {
583
594
  insertBefore(node,
584
595
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
585
596
  child) {
586
- throw new unexpected_call_error_1.default('Not supported "insertBefore" method');
597
+ throw new UnexpectedCallError('Not supported "insertBefore" method');
587
598
  }
588
599
  /**
589
600
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -599,7 +610,7 @@ class MLNode extends token_1.MLToken {
599
610
  * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
600
611
  */
601
612
  isDefaultNamespace(namespace) {
602
- throw new unexpected_call_error_1.default('Not supported "isDefaultNamespace" method');
613
+ throw new UnexpectedCallError('Not supported "isDefaultNamespace" method');
603
614
  }
604
615
  /**
605
616
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -611,7 +622,7 @@ class MLNode extends token_1.MLToken {
611
622
  isEqualNode(
612
623
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
613
624
  otherNode) {
614
- throw new unexpected_call_error_1.default('Not supported "isEqualNode" method');
625
+ throw new UnexpectedCallError('Not supported "isEqualNode" method');
615
626
  }
616
627
  /**
617
628
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -629,7 +640,7 @@ class MLNode extends token_1.MLToken {
629
640
  isSameNode(
630
641
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
631
642
  otherNode) {
632
- throw new unexpected_call_error_1.default('Not supported "isSameNode" method');
643
+ throw new UnexpectedCallError('Not supported "isSameNode" method');
633
644
  }
634
645
  /**
635
646
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -639,7 +650,7 @@ class MLNode extends token_1.MLToken {
639
650
  * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
640
651
  */
641
652
  lookupNamespaceURI(prefix) {
642
- throw new unexpected_call_error_1.default('Not supported "lookupNamespaceURI" method');
653
+ throw new UnexpectedCallError('Not supported "lookupNamespaceURI" method');
643
654
  }
644
655
  /**
645
656
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -649,7 +660,7 @@ class MLNode extends token_1.MLToken {
649
660
  * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
650
661
  */
651
662
  lookupPrefix(namespace) {
652
- throw new unexpected_call_error_1.default('Not supported "lookupPrefix" method');
663
+ throw new UnexpectedCallError('Not supported "lookupPrefix" method');
653
664
  }
654
665
  /**
655
666
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -659,7 +670,7 @@ class MLNode extends token_1.MLToken {
659
670
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-normalize%E2%91%A0
660
671
  */
661
672
  normalize() {
662
- throw new unexpected_call_error_1.default('Not supported "normalize" method');
673
+ throw new UnexpectedCallError('Not supported "normalize" method');
663
674
  }
664
675
  /**
665
676
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -669,7 +680,7 @@ class MLNode extends token_1.MLToken {
669
680
  * @see https://dom.spec.whatwg.org/#dom-node-removechild
670
681
  */
671
682
  removeChild(child) {
672
- throw new unexpected_call_error_1.default('Not supported "removeChild" method');
683
+ throw new UnexpectedCallError('Not supported "removeChild" method');
673
684
  }
674
685
  /**
675
686
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -681,7 +692,7 @@ class MLNode extends token_1.MLToken {
681
692
  removeEventListener(type,
682
693
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
683
694
  callback, options = {}) {
684
- throw new unexpected_call_error_1.default('Not supported "removeEventListener" method');
695
+ throw new UnexpectedCallError('Not supported "removeEventListener" method');
685
696
  }
686
697
  /**
687
698
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -693,7 +704,7 @@ class MLNode extends token_1.MLToken {
693
704
  replaceChild(
694
705
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
695
706
  node, child) {
696
- throw new unexpected_call_error_1.default('Not supported "removeChild" method');
707
+ throw new UnexpectedCallError('Not supported "removeChild" method');
697
708
  }
698
709
  /**
699
710
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -701,8 +712,7 @@ class MLNode extends token_1.MLToken {
701
712
  resetChildren(
702
713
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
703
714
  childNodes) {
704
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, childNodes !== null && childNodes !== void 0 ? childNodes : tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
715
+ __classPrivateFieldSet(this, _MLNode_childNodes, childNodes ?? __classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
705
716
  }
706
717
  }
707
- exports.MLNode = MLNode;
708
718
  _MLNode_childNodes = new WeakMap(), _MLNode_ownerDocument = new WeakMap(), _MLNode_prevToken = new WeakMap();
@@ -1,75 +1,66 @@
1
- import type { MLElement } from './element';
2
- import type { MLASTAbstractNode } from '@markuplint/ml-ast';
1
+ import type { MLElement } from './element.js';
2
+ import type { MLASTNode } from '@markuplint/ml-ast';
3
3
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
- import { MLNode } from './node';
4
+ import { MLNode } from './node.js';
5
5
  /**
6
6
  *
7
7
  * @see https://dom.spec.whatwg.org/#interface-parentnode
8
8
  */
9
- export declare abstract class MLParentNode<
10
- T extends RuleConfigValue,
11
- O extends PlainData = undefined,
12
- A extends MLASTAbstractNode = MLASTAbstractNode,
13
- >
14
- extends MLNode<T, O, A>
15
- implements ParentNode
16
- {
17
- #private;
18
- /**
19
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
20
- * @see https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
21
- */
22
- get childElementCount(): number;
23
- /**
24
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
25
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-children%E2%91%A0
26
- */
27
- get children(): HTMLCollectionOf<MLElement<T, O>>;
28
- /**
29
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
30
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-firstelementchild%E2%91%A0
31
- */
32
- get firstElementChild(): MLElement<T, O> | null;
33
- /**
34
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
35
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-lastelementchild%E2%91%A0
36
- */
37
- get lastElementChild(): MLElement<T, O> | null;
38
- /**
39
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
40
- *
41
- * @unsupported
42
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
43
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-append%E2%91%A0
44
- */
45
- append(...nodes: (string | Node)[]): void;
46
- /**
47
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
48
- *
49
- * @unsupported
50
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
51
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-prepend%E2%91%A0
52
- */
53
- prepend(...nodes: (string | Node)[]): void;
54
- /**
55
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
56
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselector%E2%91%A0
57
- */
58
- querySelector(selectors: string): MLElement<T, O> | null;
59
- /**
60
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
61
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselectorall%E2%91%A0
62
- */
63
- querySelectorAll(selectors: string): NodeListOf<MLElement<T, O>>;
64
- /**
65
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
66
- *
67
- * @unsupported
68
- * @implements DOM API: `Element`, `Document`, `DocumentFragment`
69
- * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-replacechildren%E2%91%A0
70
- */
71
- replaceChildren(...nodes: (string | Node)[]): void;
72
- protected _descendantsToArray<N extends MLNode<T, O>>(
73
- filter?: (node: MLNode<T, O>) => N | null | void,
74
- ): ReadonlyArray<N>;
9
+ export declare abstract class MLParentNode<T extends RuleConfigValue, O extends PlainData = undefined, A extends MLASTNode = MLASTNode> extends MLNode<T, O, A> implements ParentNode {
10
+ #private;
11
+ /**
12
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
13
+ * @see https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
14
+ */
15
+ get childElementCount(): number;
16
+ /**
17
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
18
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-children%E2%91%A0
19
+ */
20
+ get children(): HTMLCollectionOf<MLElement<T, O>>;
21
+ /**
22
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
23
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-firstelementchild%E2%91%A0
24
+ */
25
+ get firstElementChild(): MLElement<T, O> | null;
26
+ /**
27
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
28
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-lastelementchild%E2%91%A0
29
+ */
30
+ get lastElementChild(): MLElement<T, O> | null;
31
+ /**
32
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
33
+ *
34
+ * @unsupported
35
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
36
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-append%E2%91%A0
37
+ */
38
+ append(...nodes: (string | Node)[]): void;
39
+ /**
40
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
41
+ *
42
+ * @unsupported
43
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
44
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-prepend%E2%91%A0
45
+ */
46
+ prepend(...nodes: (string | Node)[]): void;
47
+ /**
48
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
49
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselector%E2%91%A0
50
+ */
51
+ querySelector(selectors: string): MLElement<T, O> | null;
52
+ /**
53
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
54
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselectorall%E2%91%A0
55
+ */
56
+ querySelectorAll(selectors: string): NodeListOf<MLElement<T, O>>;
57
+ /**
58
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
59
+ *
60
+ * @unsupported
61
+ * @implements DOM API: `Element`, `Document`, `DocumentFragment`
62
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-replacechildren%E2%91%A0
63
+ */
64
+ replaceChildren(...nodes: (string | Node)[]): void;
65
+ protected _descendantsToArray<N extends MLNode<T, O>>(filter?: (node: MLNode<T, O>) => N | null | void): ReadonlyArray<N>;
75
66
  }