@markuplint/ml-core 3.4.0 → 3.5.0

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 (65) hide show
  1. package/lib/configs.js +1 -2
  2. package/lib/index.d.ts +1 -11
  3. package/lib/ml-core.d.ts +12 -23
  4. package/lib/ml-core.js +4 -4
  5. package/lib/ml-dom/helper/accname.js +15 -5
  6. package/lib/ml-dom/helper/create-node.d.ts +2 -5
  7. package/lib/ml-dom/helper/create-node.js +3 -1
  8. package/lib/ml-dom/helper/debug.js +6 -2
  9. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  10. package/lib/ml-dom/helper/getIndent.js +11 -3
  11. package/lib/ml-dom/helper/walkers.d.ts +5 -13
  12. package/lib/ml-dom/helper/walkers.js +3 -1
  13. package/lib/ml-dom/manipulations/child-node-methods.d.ts +7 -20
  14. package/lib/ml-dom/manipulations/child-node-methods.js +24 -6
  15. package/lib/ml-dom/manipulations/get-children.d.ts +2 -4
  16. package/lib/ml-dom/manipulations/get-children.js +3 -1
  17. package/lib/ml-dom/node/attr.d.ts +91 -91
  18. package/lib/ml-dom/node/attr.js +5 -1
  19. package/lib/ml-dom/node/block.d.ts +32 -32
  20. package/lib/ml-dom/node/block.js +14 -4
  21. package/lib/ml-dom/node/character-data.d.ts +53 -60
  22. package/lib/ml-dom/node/character-data.js +9 -3
  23. package/lib/ml-dom/node/child-node.d.ts +3 -8
  24. package/lib/ml-dom/node/child-node.js +3 -1
  25. package/lib/ml-dom/node/comment.d.ts +13 -16
  26. package/lib/ml-dom/node/document-fragment.d.ts +20 -23
  27. package/lib/ml-dom/node/document-type.d.ts +32 -35
  28. package/lib/ml-dom/node/document-type.js +14 -4
  29. package/lib/ml-dom/node/document.d.ts +1586 -1599
  30. package/lib/ml-dom/node/document.js +29 -7
  31. package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
  32. package/lib/ml-dom/node/dom-token-list.js +3 -1
  33. package/lib/ml-dom/node/element.d.ts +1897 -1895
  34. package/lib/ml-dom/node/element.js +58 -14
  35. package/lib/ml-dom/node/named-node-map.d.ts +40 -45
  36. package/lib/ml-dom/node/named-node-map.js +9 -3
  37. package/lib/ml-dom/node/node-list.d.ts +4 -10
  38. package/lib/ml-dom/node/node-list.js +6 -2
  39. package/lib/ml-dom/node/node-store.d.ts +4 -4
  40. package/lib/ml-dom/node/node-store.js +8 -3
  41. package/lib/ml-dom/node/node.d.ts +472 -492
  42. package/lib/ml-dom/node/node.js +42 -14
  43. package/lib/ml-dom/node/parent-node.d.ts +58 -67
  44. package/lib/ml-dom/node/parent-node.js +9 -3
  45. package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
  46. package/lib/ml-dom/node/rule-mapper.js +6 -2
  47. package/lib/ml-dom/node/text.d.ts +47 -50
  48. package/lib/ml-dom/node/types.d.ts +13 -69
  49. package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -1
  50. package/lib/ml-dom/token/token.d.ts +44 -44
  51. package/lib/ml-rule/create-rule.d.ts +2 -2
  52. package/lib/ml-rule/create-test-rule.d.ts +4 -6
  53. package/lib/ml-rule/ml-rule-context.d.ts +49 -57
  54. package/lib/ml-rule/ml-rule-context.js +3 -1
  55. package/lib/ml-rule/ml-rule.d.ts +25 -27
  56. package/lib/ml-rule/ml-rule.js +30 -24
  57. package/lib/ml-rule/types.d.ts +16 -22
  58. package/lib/plugin/plugin.d.ts +1 -1
  59. package/lib/plugin/types.d.ts +7 -7
  60. package/lib/ruleset/index.d.ts +4 -4
  61. package/lib/ruleset/index.js +4 -4
  62. package/lib/test/index.d.ts +8 -20
  63. package/lib/types.d.ts +9 -8
  64. package/lib/utils/get-location-from-chars.d.ts +4 -9
  65. package/package.json +14 -12
@@ -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`
@@ -411,8 +413,12 @@ class MLNode extends token_1.MLToken {
411
413
  throw new Error('Invalid call: Some rule evaluations may not be running asynchronously.');
412
414
  }
413
415
  const name = this.ownerMLDocument.currentRule.name;
414
- const rule = this.rules[name];
415
- return this.ownerMLDocument.currentRule.optimizeOption(rule);
416
+ const settingRule = this.rules[name];
417
+ const rule = this.ownerMLDocument.currentRule.optimizeOption(settingRule);
418
+ if (!rule) {
419
+ throw new Error(`Rule data "${name}" doesn't exist in rules ([${Object.keys(this.rules).map(name => `"${name}"`)}]) of ${this.nodeName}("${this.raw}")`);
420
+ }
421
+ return rule;
416
422
  }
417
423
  /**
418
424
  * Returns a syntactical parent node
@@ -477,7 +483,9 @@ class MLNode extends token_1.MLToken {
477
483
  * @implements DOM API: `EventTarget`
478
484
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-addeventlistener%E2%91%A2
479
485
  */
480
- addEventListener(type, callback, options = {}) {
486
+ addEventListener(type,
487
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
488
+ callback, options = {}) {
481
489
  throw new unexpected_call_error_1.default('Not supported "addEventListener" method');
482
490
  }
483
491
  /**
@@ -507,7 +515,9 @@ class MLNode extends token_1.MLToken {
507
515
  * @implements DOM API: `Node`
508
516
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-comparedocumentposition%E2%91%A0
509
517
  */
510
- compareDocumentPosition(other) {
518
+ compareDocumentPosition(
519
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
520
+ other) {
511
521
  throw new unexpected_call_error_1.default('Not supported "compareDocumentPosition" method');
512
522
  }
513
523
  /**
@@ -517,7 +527,9 @@ class MLNode extends token_1.MLToken {
517
527
  * @implements DOM API: `Node`
518
528
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-contains%E2%91%A0
519
529
  */
520
- contains(other) {
530
+ contains(
531
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
532
+ other) {
521
533
  throw new unexpected_call_error_1.default('Not supported "contains" method');
522
534
  }
523
535
  /**
@@ -527,7 +539,9 @@ class MLNode extends token_1.MLToken {
527
539
  * @implements DOM API: `EventTarget`
528
540
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-dispatchevent%E2%91%A2
529
541
  */
530
- dispatchEvent(event) {
542
+ dispatchEvent(
543
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
544
+ event) {
531
545
  throw new unexpected_call_error_1.default('Not supported "dispatchEvent" method');
532
546
  }
533
547
  /**
@@ -537,7 +551,9 @@ class MLNode extends token_1.MLToken {
537
551
  * @implements DOM API: `Node`
538
552
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-getrootnode%E2%91%A0
539
553
  */
540
- getRootNode(options) {
554
+ getRootNode(
555
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
556
+ options) {
541
557
  if (options) {
542
558
  throw new unexpected_call_error_1.default('Not supported options');
543
559
  }
@@ -561,7 +577,9 @@ class MLNode extends token_1.MLToken {
561
577
  * @implements DOM API: `Node`
562
578
  * @see https://dom.spec.whatwg.org/#dom-node-insertbefore
563
579
  */
564
- insertBefore(node, child) {
580
+ insertBefore(node,
581
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
582
+ child) {
565
583
  throw new unexpected_call_error_1.default('Not supported "insertBefore" method');
566
584
  }
567
585
  /**
@@ -587,7 +605,9 @@ class MLNode extends token_1.MLToken {
587
605
  * @implements DOM API: `Node`
588
606
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-isequalnode%E2%91%A0
589
607
  */
590
- isEqualNode(otherNode) {
608
+ isEqualNode(
609
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
610
+ otherNode) {
591
611
  throw new unexpected_call_error_1.default('Not supported "isEqualNode" method');
592
612
  }
593
613
  /**
@@ -603,7 +623,9 @@ class MLNode extends token_1.MLToken {
603
623
  * @implements DOM API: `Node`
604
624
  * @see https://dom.spec.whatwg.org/#dom-node-issamenode
605
625
  */
606
- isSameNode(otherNode) {
626
+ isSameNode(
627
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
628
+ otherNode) {
607
629
  throw new unexpected_call_error_1.default('Not supported "isSameNode" method');
608
630
  }
609
631
  /**
@@ -653,7 +675,9 @@ class MLNode extends token_1.MLToken {
653
675
  * @implements DOM API: `EventTarget`
654
676
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-removeeventlistener%E2%91%A1
655
677
  */
656
- removeEventListener(type, callback, options = {}) {
678
+ removeEventListener(type,
679
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
680
+ callback, options = {}) {
657
681
  throw new unexpected_call_error_1.default('Not supported "removeEventListener" method');
658
682
  }
659
683
  /**
@@ -663,13 +687,17 @@ class MLNode extends token_1.MLToken {
663
687
  * @implements DOM API: `Node`
664
688
  * @see https://dom.spec.whatwg.org/#dom-node-replacechild
665
689
  */
666
- replaceChild(node, child) {
690
+ replaceChild(
691
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
692
+ node, child) {
667
693
  throw new unexpected_call_error_1.default('Not supported "removeChild" method');
668
694
  }
669
695
  /**
670
696
  * @implements `@markuplint/ml-core` API: `MLNode`
671
697
  */
672
- resetChildren(childNodes) {
698
+ resetChildren(
699
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
700
+ childNodes) {
673
701
  tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, childNodes !== null && childNodes !== void 0 ? childNodes : tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
674
702
  }
675
703
  }
@@ -1,75 +1,66 @@
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<
10
- T extends RuleConfigValue,
11
- O = null,
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 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> | 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
  }
@@ -64,7 +64,9 @@ class MLParentNode extends node_1.MLNode {
64
64
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
65
65
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-append%E2%91%A0
66
66
  */
67
- append(...nodes) {
67
+ append(
68
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
69
+ ...nodes) {
68
70
  throw new unexpected_call_error_1.default('Not supported "append" method');
69
71
  }
70
72
  /**
@@ -74,7 +76,9 @@ class MLParentNode extends node_1.MLNode {
74
76
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
75
77
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-prepend%E2%91%A0
76
78
  */
77
- prepend(...nodes) {
79
+ prepend(
80
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
81
+ ...nodes) {
78
82
  throw new unexpected_call_error_1.default('Not supported "prepend" method');
79
83
  }
80
84
  /**
@@ -109,7 +113,9 @@ class MLParentNode extends node_1.MLNode {
109
113
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
110
114
  * @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-replacechildren%E2%91%A0
111
115
  */
112
- replaceChildren(...nodes) {
116
+ replaceChildren(
117
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
118
+ ...nodes) {
113
119
  throw new unexpected_call_error_1.default('Not supported "replaceChildren" method');
114
120
  }
115
121
  _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");
@@ -32,7 +34,9 @@ class RuleMapper {
32
34
  });
33
35
  });
34
36
  }
35
- set(node, ruleName, rule) {
37
+ set(
38
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
39
+ node, ruleName, rule) {
36
40
  const rules = tslib_1.__classPrivateFieldGet(this, _RuleMapper_ruleMap, "f").get(node.uuid) || {};
37
41
  const currentRule = rules[ruleName];
38
42
  if (currentRule) {
@@ -1,54 +1,51 @@
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>
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;
5
+ export declare class MLText<T extends RuleConfigValue, O extends PlainData = undefined> 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;
54
51
  }
@@ -8,54 +8,10 @@ import type { MLElement } from './element';
8
8
  import type { MLNode } from './node';
9
9
  import type { MLText } from './text';
10
10
  import type { MLToken } from '../token/token';
11
- import type {
12
- MLASTAbstractNode,
13
- MLASTAttr,
14
- MLASTComment,
15
- MLASTDoctype,
16
- MLASTElement,
17
- MLASTParentNode,
18
- MLASTPreprocessorSpecificBlock,
19
- MLASTText,
20
- MLToken as MLASTToken,
21
- } from '@markuplint/ml-ast/';
22
- import type { PretenderARIA, RuleConfigValue } from '@markuplint/ml-config';
23
- export type MappedNode<N, T extends RuleConfigValue, O = null> = N extends MLASTElement
24
- ? MLElement<T, O>
25
- : N extends MLASTParentNode
26
- ? MLElement<T, O>
27
- : N extends MLASTComment
28
- ? MLComment<T, O>
29
- : N extends MLASTText
30
- ? MLText<T, O>
31
- : N extends MLASTDoctype
32
- ? MLDocumentType<T, O>
33
- : N extends MLASTPreprocessorSpecificBlock
34
- ? MLBlock<T, O>
35
- : N extends MLASTAbstractNode
36
- ? MLNode<T, O, MLASTAbstractNode>
37
- : N extends MLASTAttr
38
- ? MLAttr<T, O>
39
- : N extends MLASTToken
40
- ? MLToken
41
- : never;
42
- export type NodeTypeOf<NT extends NodeType, T extends RuleConfigValue, O = null> = NT extends ElementNodeType
43
- ? MLElement<T, O>
44
- : NT extends CommentNodeType
45
- ? MLComment<T, O>
46
- : NT extends TextNodeType
47
- ? MLText<T, O>
48
- : NT extends DocumentNodeType
49
- ? MLDocument<T, O>
50
- : NT extends DocumentTypeNodeType
51
- ? MLDocumentType<T, O>
52
- : NT extends DocumentFragmentNodeType
53
- ? MLDocumentFragment<T, O>
54
- : NT extends MarkuplintPreprocessorBlockType
55
- ? MLBlock<T, O>
56
- : NT extends AttributeNodeType
57
- ? MLAttr<T, O>
58
- : never;
11
+ import type { MLASTAbstractNode, MLASTAttr, MLASTComment, MLASTDoctype, MLASTElement, MLASTParentNode, MLASTPreprocessorSpecificBlock, MLASTText, MLToken as MLASTToken } from '@markuplint/ml-ast/';
12
+ import type { PlainData, PretenderARIA, RuleConfigValue } from '@markuplint/ml-config';
13
+ export type MappedNode<N, T extends RuleConfigValue, O extends PlainData = undefined> = N extends MLASTElement ? MLElement<T, O> : N extends MLASTParentNode ? MLElement<T, O> : N extends MLASTComment ? MLComment<T, O> : N extends MLASTText ? MLText<T, O> : N extends MLASTDoctype ? MLDocumentType<T, O> : N extends MLASTPreprocessorSpecificBlock ? MLBlock<T, O> : N extends MLASTAbstractNode ? MLNode<T, O, MLASTAbstractNode> : N extends MLASTAttr ? MLAttr<T, O> : N extends MLASTToken ? MLToken : never;
14
+ export type NodeTypeOf<NT extends NodeType, T extends RuleConfigValue, O extends PlainData = undefined> = NT extends ElementNodeType ? MLElement<T, O> : NT extends CommentNodeType ? MLComment<T, O> : NT extends TextNodeType ? MLText<T, O> : NT extends DocumentNodeType ? MLDocument<T, O> : NT extends DocumentTypeNodeType ? MLDocumentType<T, O> : NT extends DocumentFragmentNodeType ? MLDocumentFragment<T, O> : NT extends MarkuplintPreprocessorBlockType ? MLBlock<T, O> : NT extends AttributeNodeType ? MLAttr<T, O> : never;
59
15
  export type ElementNodeType = 1;
60
16
  export type AttributeNodeType = 2;
61
17
  export type TextNodeType = 3;
@@ -66,26 +22,14 @@ export type DocumentNodeType = 9;
66
22
  export type DocumentTypeNodeType = 10;
67
23
  export type DocumentFragmentNodeType = 11;
68
24
  export type MarkuplintPreprocessorBlockType = 101;
69
- export type NodeType =
70
- | ElementNodeType
71
- | AttributeNodeType
72
- | TextNodeType
73
- | CDATASectionNodeType
74
- | ProcessingInstructionNodeType
75
- | CommentNodeType
76
- | DocumentNodeType
77
- | DocumentTypeNodeType
78
- | DocumentFragmentNodeType
79
- | MarkuplintPreprocessorBlockType;
80
- export type PretenderContext<N extends MLElement<T, O>, T extends RuleConfigValue, O = null> =
81
- | PretenderContextPretender<N, T, O>
82
- | PretenderContextPretended<N, T, O>;
83
- export type PretenderContextPretender<N extends MLElement<T, O>, T extends RuleConfigValue, O = null> = {
84
- readonly type: 'pretender';
85
- readonly as: N;
86
- readonly aria?: PretenderARIA;
25
+ export type NodeType = ElementNodeType | AttributeNodeType | TextNodeType | CDATASectionNodeType | ProcessingInstructionNodeType | CommentNodeType | DocumentNodeType | DocumentTypeNodeType | DocumentFragmentNodeType | MarkuplintPreprocessorBlockType;
26
+ export type PretenderContext<N extends MLElement<T, O>, T extends RuleConfigValue, O extends PlainData = undefined> = PretenderContextPretender<N, T, O> | PretenderContextPretended<N, T, O>;
27
+ export type PretenderContextPretender<N extends MLElement<T, O>, T extends RuleConfigValue, O extends PlainData = undefined> = {
28
+ readonly type: 'pretender';
29
+ readonly as: N;
30
+ readonly aria?: PretenderARIA;
87
31
  };
88
- export type PretenderContextPretended<N extends MLElement<T, O>, T extends RuleConfigValue, O = null> = {
89
- readonly type: 'origin';
90
- readonly origin: N;
32
+ export type PretenderContextPretended<N extends MLElement<T, O>, T extends RuleConfigValue, O extends PlainData = undefined> = {
33
+ readonly type: 'origin';
34
+ readonly origin: N;
91
35
  };
@@ -1 +1,2 @@
1
- export default class UnexpectedCallError extends Error {}
1
+ export default class UnexpectedCallError extends Error {
2
+ }
@@ -1,47 +1,47 @@
1
1
  import type { MLToken as MLASTToken } from '@markuplint/ml-ast';
2
2
  export declare class MLToken<A extends MLASTToken = MLASTToken> {
3
- #private;
4
- readonly uuid: string;
5
- protected readonly _astToken: A;
6
- constructor(astToken: A);
7
- /**
8
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
9
- */
10
- get endCol(): number;
11
- /**
12
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
13
- */
14
- get endLine(): number;
15
- /**
16
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
17
- */
18
- get endOffset(): number;
19
- /**
20
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
21
- */
22
- get originRaw(): string;
23
- /**
24
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
25
- */
26
- get raw(): string;
27
- /**
28
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
29
- */
30
- get startCol(): number;
31
- /**
32
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
33
- */
34
- get startLine(): number;
35
- /**
36
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
37
- */
38
- get startOffset(): number;
39
- /**
40
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
41
- */
42
- fix(raw: string): void;
43
- /**
44
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
45
- */
46
- toString(): string;
3
+ #private;
4
+ readonly uuid: string;
5
+ protected readonly _astToken: A;
6
+ constructor(astToken: A);
7
+ /**
8
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
9
+ */
10
+ get endCol(): number;
11
+ /**
12
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
13
+ */
14
+ get endLine(): number;
15
+ /**
16
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
17
+ */
18
+ get endOffset(): number;
19
+ /**
20
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
21
+ */
22
+ get originRaw(): string;
23
+ /**
24
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
25
+ */
26
+ get raw(): string;
27
+ /**
28
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
29
+ */
30
+ get startCol(): number;
31
+ /**
32
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
33
+ */
34
+ get startLine(): number;
35
+ /**
36
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
37
+ */
38
+ get startOffset(): number;
39
+ /**
40
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
41
+ */
42
+ fix(raw: string): void;
43
+ /**
44
+ * @implements `@markuplint/ml-core` API: `MLDOMToken`
45
+ */
46
+ toString(): string;
47
47
  }