@markuplint/ml-core 3.0.0-canary.5 → 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 (74) hide show
  1. package/README.md +1 -1
  2. package/lib/configs.browser.d.ts +2 -0
  3. package/lib/configs.browser.js +12 -0
  4. package/lib/configs.js +1 -2
  5. package/lib/index.d.ts +11 -1
  6. package/lib/ml-core.d.ts +23 -12
  7. package/lib/ml-core.js +4 -4
  8. package/lib/ml-dom/helper/accname.js +18 -7
  9. package/lib/ml-dom/helper/create-node.d.ts +6 -2
  10. package/lib/ml-dom/helper/create-node.js +3 -1
  11. package/lib/ml-dom/helper/debug.js +9 -4
  12. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  13. package/lib/ml-dom/helper/getIndent.js +18 -12
  14. package/lib/ml-dom/helper/walkers.d.ts +15 -5
  15. package/lib/ml-dom/helper/walkers.js +22 -16
  16. package/lib/ml-dom/manipulations/child-node-methods.d.ts +20 -7
  17. package/lib/ml-dom/manipulations/child-node-methods.js +24 -6
  18. package/lib/ml-dom/manipulations/get-children.d.ts +4 -2
  19. package/lib/ml-dom/manipulations/get-children.js +3 -1
  20. package/lib/ml-dom/node/attr.d.ts +94 -91
  21. package/lib/ml-dom/node/attr.js +8 -4
  22. package/lib/ml-dom/node/block.d.ts +36 -32
  23. package/lib/ml-dom/node/block.js +14 -4
  24. package/lib/ml-dom/node/character-data.d.ts +60 -53
  25. package/lib/ml-dom/node/character-data.js +9 -3
  26. package/lib/ml-dom/node/child-node.d.ts +10 -3
  27. package/lib/ml-dom/node/child-node.js +3 -1
  28. package/lib/ml-dom/node/comment.d.ts +16 -13
  29. package/lib/ml-dom/node/document-fragment.d.ts +23 -20
  30. package/lib/ml-dom/node/document-type.d.ts +35 -32
  31. package/lib/ml-dom/node/document-type.js +14 -4
  32. package/lib/ml-dom/node/document.d.ts +1607 -1589
  33. package/lib/ml-dom/node/document.js +56 -19
  34. package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
  35. package/lib/ml-dom/node/dom-token-list.js +9 -7
  36. package/lib/ml-dom/node/element.d.ts +1903 -1889
  37. package/lib/ml-dom/node/element.js +76 -27
  38. package/lib/ml-dom/node/named-node-map.d.ts +45 -40
  39. package/lib/ml-dom/node/named-node-map.js +13 -5
  40. package/lib/ml-dom/node/node-list.d.ts +10 -4
  41. package/lib/ml-dom/node/node-list.js +25 -5
  42. package/lib/ml-dom/node/node-store.d.ts +9 -4
  43. package/lib/ml-dom/node/node-store.js +19 -1
  44. package/lib/ml-dom/node/node.d.ts +493 -473
  45. package/lib/ml-dom/node/node.js +52 -19
  46. package/lib/ml-dom/node/parent-node.d.ts +67 -58
  47. package/lib/ml-dom/node/parent-node.js +15 -6
  48. package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
  49. package/lib/ml-dom/node/rule-mapper.js +11 -3
  50. package/lib/ml-dom/node/text.d.ts +50 -47
  51. package/lib/ml-dom/node/types.d.ts +82 -14
  52. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -2
  53. package/lib/ml-dom/token/token.d.ts +44 -44
  54. package/lib/ml-rule/create-rule.d.ts +4 -2
  55. package/lib/ml-rule/create-test-rule.d.ts +6 -4
  56. package/lib/ml-rule/ml-rule-context.d.ts +58 -50
  57. package/lib/ml-rule/ml-rule-context.js +4 -2
  58. package/lib/ml-rule/ml-rule.d.ts +36 -26
  59. package/lib/ml-rule/ml-rule.js +37 -32
  60. package/lib/ml-rule/types.d.ts +35 -17
  61. package/lib/plugin/plugin.d.ts +3 -1
  62. package/lib/plugin/types.d.ts +7 -7
  63. package/lib/ruleset/index.d.ts +4 -4
  64. package/lib/ruleset/index.js +4 -4
  65. package/lib/test/index.d.ts +20 -8
  66. package/lib/test/index.js +1 -1
  67. package/lib/types.d.ts +9 -8
  68. package/lib/utils/get-location-from-chars.d.ts +9 -4
  69. package/package.json +21 -15
  70. package/test/ml-dom/helper/accname.spec.js +85 -0
  71. package/test/ml-dom/helper/create-node.spec.js +18 -0
  72. package/test/ml-dom/index.spec.js +680 -0
  73. package/tsconfig.test.json +0 -3
  74. package/tsconfig.tsbuildinfo +0 -1
@@ -9,7 +9,9 @@ const node_list_1 = require("./node-list");
9
9
  const node_store_1 = require("./node-store");
10
10
  const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
11
11
  class MLNode extends token_1.MLToken {
12
- constructor(astNode, document) {
12
+ constructor(astNode,
13
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
14
+ document) {
13
15
  super(astNode);
14
16
  /**
15
17
  * @implements DOM API: `Node`
@@ -149,6 +151,7 @@ class MLNode extends token_1.MLToken {
149
151
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-childnodes%E2%91%A0
150
152
  */
151
153
  get childNodes() {
154
+ var _a;
152
155
  if (tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f") != null) {
153
156
  return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
154
157
  }
@@ -167,7 +170,7 @@ class MLNode extends token_1.MLToken {
167
170
  this.is(this.ELEMENT_NODE) ||
168
171
  this.is(this.MARKUPLINT_PREPROCESSOR_BLOCK)) {
169
172
  // @ts-ignore
170
- const astChildren = this._astToken.childNodes || [];
173
+ const astChildren = (_a = this._astToken.childNodes) !== null && _a !== void 0 ? _a : [];
171
174
  const childNodes = astChildren
172
175
  .map(node => node_store_1.nodeStore.getNode(node))
173
176
  .filter((node) => (0, child_node_1.isChildNode)(node));
@@ -187,7 +190,8 @@ class MLNode extends token_1.MLToken {
187
190
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-firstchild%E2%91%A0
188
191
  */
189
192
  get firstChild() {
190
- return this.childNodes[0] || null;
193
+ var _a;
194
+ return (_a = this.childNodes[0]) !== null && _a !== void 0 ? _a : null;
191
195
  }
192
196
  /**
193
197
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -207,7 +211,8 @@ class MLNode extends token_1.MLToken {
207
211
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-lastchild%E2%91%A0
208
212
  */
209
213
  get lastChild() {
210
- return this.childNodes[this.childNodes.length - 1] || null;
214
+ var _a;
215
+ return (_a = this.childNodes[this.childNodes.length - 1]) !== null && _a !== void 0 ? _a : null;
211
216
  }
212
217
  /**
213
218
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -367,6 +372,7 @@ class MLNode extends token_1.MLToken {
367
372
  * @implements `@markuplint/ml-core` API: `MLNode`
368
373
  */
369
374
  get prevToken() {
375
+ var _a, _b;
370
376
  if (tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f") !== undefined) {
371
377
  return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
372
378
  }
@@ -388,8 +394,8 @@ class MLNode extends token_1.MLToken {
388
394
  tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
389
395
  return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
390
396
  }
391
- tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, this.ownerMLDocument.nodeList[index - 1] || null, "f");
392
- return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f") || null;
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;
393
399
  }
394
400
  /**
395
401
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -409,8 +415,13 @@ class MLNode extends token_1.MLToken {
409
415
  throw new Error('Invalid call: Some rule evaluations may not be running asynchronously.');
410
416
  }
411
417
  const name = this.ownerMLDocument.currentRule.name;
412
- const rule = this.rules[name];
413
- return this.ownerMLDocument.currentRule.optimizeOption(rule);
418
+ const settingRule = this.rules[name];
419
+ const rule = this.ownerMLDocument.currentRule.optimizeOption(settingRule);
420
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
421
+ if (!rule) {
422
+ throw new Error(`Rule data "${name}" doesn't exist in rules ([${Object.keys(this.rules).map(name => `"${name}"`)}]) of ${this.nodeName}("${this.raw}")`);
423
+ }
424
+ return rule;
414
425
  }
415
426
  /**
416
427
  * Returns a syntactical parent node
@@ -475,7 +486,9 @@ class MLNode extends token_1.MLToken {
475
486
  * @implements DOM API: `EventTarget`
476
487
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-addeventlistener%E2%91%A2
477
488
  */
478
- addEventListener(type, callback, options = {}) {
489
+ addEventListener(type,
490
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
491
+ callback, options = {}) {
479
492
  throw new unexpected_call_error_1.default('Not supported "addEventListener" method');
480
493
  }
481
494
  /**
@@ -505,7 +518,9 @@ class MLNode extends token_1.MLToken {
505
518
  * @implements DOM API: `Node`
506
519
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-comparedocumentposition%E2%91%A0
507
520
  */
508
- compareDocumentPosition(other) {
521
+ compareDocumentPosition(
522
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
523
+ other) {
509
524
  throw new unexpected_call_error_1.default('Not supported "compareDocumentPosition" method');
510
525
  }
511
526
  /**
@@ -515,7 +530,9 @@ class MLNode extends token_1.MLToken {
515
530
  * @implements DOM API: `Node`
516
531
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-contains%E2%91%A0
517
532
  */
518
- contains(other) {
533
+ contains(
534
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
535
+ other) {
519
536
  throw new unexpected_call_error_1.default('Not supported "contains" method');
520
537
  }
521
538
  /**
@@ -525,7 +542,9 @@ class MLNode extends token_1.MLToken {
525
542
  * @implements DOM API: `EventTarget`
526
543
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-dispatchevent%E2%91%A2
527
544
  */
528
- dispatchEvent(event) {
545
+ dispatchEvent(
546
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
547
+ event) {
529
548
  throw new unexpected_call_error_1.default('Not supported "dispatchEvent" method');
530
549
  }
531
550
  /**
@@ -535,7 +554,9 @@ class MLNode extends token_1.MLToken {
535
554
  * @implements DOM API: `Node`
536
555
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-getrootnode%E2%91%A0
537
556
  */
538
- getRootNode(options) {
557
+ getRootNode(
558
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
559
+ options) {
539
560
  if (options) {
540
561
  throw new unexpected_call_error_1.default('Not supported options');
541
562
  }
@@ -559,7 +580,9 @@ class MLNode extends token_1.MLToken {
559
580
  * @implements DOM API: `Node`
560
581
  * @see https://dom.spec.whatwg.org/#dom-node-insertbefore
561
582
  */
562
- insertBefore(node, child) {
583
+ insertBefore(node,
584
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
585
+ child) {
563
586
  throw new unexpected_call_error_1.default('Not supported "insertBefore" method');
564
587
  }
565
588
  /**
@@ -585,7 +608,9 @@ class MLNode extends token_1.MLToken {
585
608
  * @implements DOM API: `Node`
586
609
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-isequalnode%E2%91%A0
587
610
  */
588
- isEqualNode(otherNode) {
611
+ isEqualNode(
612
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
613
+ otherNode) {
589
614
  throw new unexpected_call_error_1.default('Not supported "isEqualNode" method');
590
615
  }
591
616
  /**
@@ -601,7 +626,9 @@ class MLNode extends token_1.MLToken {
601
626
  * @implements DOM API: `Node`
602
627
  * @see https://dom.spec.whatwg.org/#dom-node-issamenode
603
628
  */
604
- isSameNode(otherNode) {
629
+ isSameNode(
630
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
631
+ otherNode) {
605
632
  throw new unexpected_call_error_1.default('Not supported "isSameNode" method');
606
633
  }
607
634
  /**
@@ -651,7 +678,9 @@ class MLNode extends token_1.MLToken {
651
678
  * @implements DOM API: `EventTarget`
652
679
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-removeeventlistener%E2%91%A1
653
680
  */
654
- removeEventListener(type, callback, options = {}) {
681
+ removeEventListener(type,
682
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
683
+ callback, options = {}) {
655
684
  throw new unexpected_call_error_1.default('Not supported "removeEventListener" method');
656
685
  }
657
686
  /**
@@ -661,13 +690,17 @@ class MLNode extends token_1.MLToken {
661
690
  * @implements DOM API: `Node`
662
691
  * @see https://dom.spec.whatwg.org/#dom-node-replacechild
663
692
  */
664
- replaceChild(node, child) {
693
+ replaceChild(
694
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
695
+ node, child) {
665
696
  throw new unexpected_call_error_1.default('Not supported "removeChild" method');
666
697
  }
667
698
  /**
668
699
  * @implements `@markuplint/ml-core` API: `MLNode`
669
700
  */
670
- resetChildren(childNodes) {
701
+ resetChildren(
702
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
703
+ childNodes) {
671
704
  tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, childNodes !== null && childNodes !== void 0 ? childNodes : tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
672
705
  }
673
706
  }
@@ -1,66 +1,75 @@
1
1
  import type { MLElement } from './element';
2
2
  import type { MLASTAbstractNode } from '@markuplint/ml-ast';
3
- import type { RuleConfigValue } from '@markuplint/ml-config';
3
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  import { MLNode } from './node';
5
5
  /**
6
6
  *
7
7
  * @see https://dom.spec.whatwg.org/#interface-parentnode
8
8
  */
9
- export declare abstract class MLParentNode<T extends RuleConfigValue, O = null, A extends MLASTAbstractNode = MLASTAbstractNode> 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>;
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>;
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>;
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>;
66
75
  }
@@ -48,14 +48,16 @@ class MLParentNode extends node_1.MLNode {
48
48
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-firstelementchild%E2%91%A0
49
49
  */
50
50
  get firstElementChild() {
51
- return this.children[0] || null;
51
+ var _a;
52
+ return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
52
53
  }
53
54
  /**
54
55
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
55
56
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-lastelementchild%E2%91%A0
56
57
  */
57
58
  get lastElementChild() {
58
- return this.children[0] || null;
59
+ var _a;
60
+ return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
59
61
  }
60
62
  /**
61
63
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -64,7 +66,9 @@ class MLParentNode extends node_1.MLNode {
64
66
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
65
67
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-append%E2%91%A0
66
68
  */
67
- append(...nodes) {
69
+ append(
70
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
71
+ ...nodes) {
68
72
  throw new unexpected_call_error_1.default('Not supported "append" method');
69
73
  }
70
74
  /**
@@ -74,7 +78,9 @@ class MLParentNode extends node_1.MLNode {
74
78
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
75
79
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-prepend%E2%91%A0
76
80
  */
77
- prepend(...nodes) {
81
+ prepend(
82
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
83
+ ...nodes) {
78
84
  throw new unexpected_call_error_1.default('Not supported "prepend" method');
79
85
  }
80
86
  /**
@@ -82,8 +88,9 @@ class MLParentNode extends node_1.MLNode {
82
88
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselector%E2%91%A0
83
89
  */
84
90
  querySelector(selectors) {
91
+ var _a;
85
92
  const selected = this.querySelectorAll(selectors);
86
- return selected[0] || null;
93
+ return (_a = selected[0]) !== null && _a !== void 0 ? _a : null;
87
94
  }
88
95
  /**
89
96
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
@@ -109,7 +116,9 @@ class MLParentNode extends node_1.MLNode {
109
116
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
110
117
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-replacechildren%E2%91%A0
111
118
  */
112
- replaceChildren(...nodes) {
119
+ replaceChildren(
120
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
121
+ ...nodes) {
113
122
  throw new unexpected_call_error_1.default('Not supported "replaceChildren" method');
114
123
  }
115
124
  _descendantsToArray(filter) {
@@ -4,14 +4,14 @@ import type { AnyRule } from '@markuplint/ml-config';
4
4
  import type { Specificity } from '@markuplint/selector';
5
5
  type RuleType = 'rules' | 'nodeRules' | 'childNodeRules';
6
6
  type MappingLayer = {
7
- from: RuleType;
8
- specificity: Specificity;
9
- rule: AnyRule;
7
+ readonly from: RuleType;
8
+ readonly specificity: Specificity;
9
+ readonly rule: AnyRule;
10
10
  };
11
11
  export declare class RuleMapper {
12
- #private;
13
- constructor(document: MLDocument<any, any>);
14
- apply(): void;
15
- set(node: MLNode<any, any>, ruleName: string, rule: MappingLayer): void;
12
+ #private;
13
+ constructor(document: MLDocument<any, any>);
14
+ apply(): void;
15
+ set(node: MLNode<any, any>, ruleName: string, rule: MappingLayer): void;
16
16
  }
17
17
  export {};
@@ -9,7 +9,9 @@ const ruleMapperLog = debug_1.log.extend('rule-mapper');
9
9
  const ruleMapperNodeLog = ruleMapperLog.extend('node');
10
10
  const ruleMapperNodeRuleLog = ruleMapperNodeLog.extend('rule');
11
11
  class RuleMapper {
12
- constructor(document) {
12
+ constructor(
13
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
14
+ document) {
13
15
  _RuleMapper_nodeList.set(this, void 0);
14
16
  _RuleMapper_ruleMap.set(this, new Map());
15
17
  tslib_1.__classPrivateFieldSet(this, _RuleMapper_nodeList, Object.freeze([document, ...document.nodeList]), "f");
@@ -24,13 +26,19 @@ class RuleMapper {
24
26
  ruleMapperNodeLog('<%s>', node.nodeName);
25
27
  Object.keys(rules).forEach(ruleName => {
26
28
  const rule = rules[ruleName];
29
+ if (!rule) {
30
+ return;
31
+ }
27
32
  node.rules[ruleName] = rule.rule;
28
33
  ruleMapperNodeRuleLog('[from: %s(%s)] %s: %o', rule.from, rule.specificity, ruleName, rule.rule);
29
34
  });
30
35
  });
31
36
  }
32
- set(node, ruleName, rule) {
33
- const rules = tslib_1.__classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid) || {};
37
+ set(
38
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
39
+ node, ruleName, rule) {
40
+ var _a;
41
+ const rules = (_a = tslib_1.__classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid)) !== null && _a !== void 0 ? _a : {};
34
42
  const currentRule = rules[ruleName];
35
43
  if (currentRule) {
36
44
  const order = (0, selector_1.compareSpecificity)(currentRule.specificity, rule.specificity);
@@ -1,51 +1,54 @@
1
1
  import type { TextNodeType } from './types';
2
2
  import type { MLASTText } from '@markuplint/ml-ast';
3
- import type { RuleConfigValue } from '@markuplint/ml-config';
3
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  import { MLCharacterData } from './character-data';
5
- export declare class MLText<T extends RuleConfigValue, O = null> extends MLCharacterData<T, O, MLASTText> implements Text {
6
- /**
7
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
8
- *
9
- * @unsupported
10
- * @implements DOM API: `Text`
11
- */
12
- get assignedSlot(): HTMLSlotElement;
13
- /**
14
- * Returns a string appropriate for the type of node as `Text`
15
- *
16
- * @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
17
- */
18
- get nodeName(): "#text";
19
- /**
20
- * Returns a number appropriate for the type of `Text`
21
- */
22
- get nodeType(): TextNodeType;
23
- get textContent(): string | null;
24
- /**
25
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
26
- *
27
- * @unsupported
28
- * @implements DOM API: `Text`
29
- * @see https://dom.spec.whatwg.org/#ref-for-dom-text-splittext%E2%91%A0
30
- */
31
- get wholeText(): string;
32
- /**
33
- * Returns `true` if a parent element is `<script>` or `<style>`
34
- *
35
- * @implements `@markuplint/ml-core` API: `MLText`
36
- * @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
37
- */
38
- isRawTextElementContent(): boolean;
39
- /**
40
- * @implements `@markuplint/ml-core` API: `MLText`
41
- */
42
- isWhitespace(): boolean;
43
- /**
44
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
45
- *
46
- * @unsupported
47
- * @implements DOM API: `Text`
48
- * @see https://dom.spec.whatwg.org/#ref-for-dom-text-wholetext%E2%91%A0
49
- */
50
- splitText(offset: number): Text;
5
+ export declare class MLText<T extends RuleConfigValue, O extends PlainData = undefined>
6
+ extends MLCharacterData<T, O, MLASTText>
7
+ implements Text
8
+ {
9
+ /**
10
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
11
+ *
12
+ * @unsupported
13
+ * @implements DOM API: `Text`
14
+ */
15
+ get assignedSlot(): HTMLSlotElement;
16
+ /**
17
+ * Returns a string appropriate for the type of node as `Text`
18
+ *
19
+ * @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
20
+ */
21
+ get nodeName(): '#text';
22
+ /**
23
+ * Returns a number appropriate for the type of `Text`
24
+ */
25
+ get nodeType(): TextNodeType;
26
+ get textContent(): string | null;
27
+ /**
28
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
29
+ *
30
+ * @unsupported
31
+ * @implements DOM API: `Text`
32
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-text-splittext%E2%91%A0
33
+ */
34
+ get wholeText(): string;
35
+ /**
36
+ * Returns `true` if a parent element is `<script>` or `<style>`
37
+ *
38
+ * @implements `@markuplint/ml-core` API: `MLText`
39
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
40
+ */
41
+ isRawTextElementContent(): boolean;
42
+ /**
43
+ * @implements `@markuplint/ml-core` API: `MLText`
44
+ */
45
+ isWhitespace(): boolean;
46
+ /**
47
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
48
+ *
49
+ * @unsupported
50
+ * @implements DOM API: `Text`
51
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-text-wholetext%E2%91%A0
52
+ */
53
+ splitText(offset: number): Text;
51
54
  }