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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +12 -3
  2. package/lib/configs.browser.d.ts +2 -0
  3. package/lib/configs.browser.js +12 -0
  4. package/lib/configs.js +4 -1
  5. package/lib/index.d.ts +11 -1
  6. package/lib/ml-core.d.ts +24 -13
  7. package/lib/ml-core.js +16 -10
  8. package/lib/ml-dom/helper/accname.d.ts +2 -1
  9. package/lib/ml-dom/helper/accname.js +62 -2
  10. package/lib/ml-dom/helper/create-node.d.ts +7 -3
  11. package/lib/ml-dom/helper/create-node.js +4 -2
  12. package/lib/ml-dom/helper/debug.js +10 -5
  13. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  14. package/lib/ml-dom/helper/getIndent.js +18 -12
  15. package/lib/ml-dom/helper/walkers.d.ts +15 -5
  16. package/lib/ml-dom/helper/walkers.js +22 -16
  17. package/lib/ml-dom/index.d.ts +1 -0
  18. package/lib/ml-dom/manipulations/child-node-methods.d.ts +20 -7
  19. package/lib/ml-dom/manipulations/child-node-methods.js +24 -6
  20. package/lib/ml-dom/manipulations/get-children.d.ts +4 -2
  21. package/lib/ml-dom/manipulations/get-children.js +3 -1
  22. package/lib/ml-dom/node/attr.d.ts +94 -91
  23. package/lib/ml-dom/node/attr.js +26 -16
  24. package/lib/ml-dom/node/block.d.ts +36 -32
  25. package/lib/ml-dom/node/block.js +14 -4
  26. package/lib/ml-dom/node/character-data.d.ts +61 -54
  27. package/lib/ml-dom/node/character-data.js +9 -3
  28. package/lib/ml-dom/node/child-node.d.ts +10 -3
  29. package/lib/ml-dom/node/child-node.js +3 -1
  30. package/lib/ml-dom/node/comment.d.ts +16 -13
  31. package/lib/ml-dom/node/document-fragment.d.ts +24 -21
  32. package/lib/ml-dom/node/document-type.d.ts +35 -32
  33. package/lib/ml-dom/node/document-type.js +14 -4
  34. package/lib/ml-dom/node/document.d.ts +1608 -1545
  35. package/lib/ml-dom/node/document.js +125 -33
  36. package/lib/ml-dom/node/dom-token-list.d.ts +27 -27
  37. package/lib/ml-dom/node/dom-token-list.js +15 -13
  38. package/lib/ml-dom/node/element.d.ts +1906 -1817
  39. package/lib/ml-dom/node/element.js +345 -75
  40. package/lib/ml-dom/node/named-node-map.d.ts +45 -40
  41. package/lib/ml-dom/node/named-node-map.js +13 -5
  42. package/lib/ml-dom/node/node-list.d.ts +10 -4
  43. package/lib/ml-dom/node/node-list.js +25 -5
  44. package/lib/ml-dom/node/node-store.d.ts +10 -5
  45. package/lib/ml-dom/node/node-store.js +19 -1
  46. package/lib/ml-dom/node/node.d.ts +494 -467
  47. package/lib/ml-dom/node/node.js +89 -47
  48. package/lib/ml-dom/node/parent-node.d.ts +68 -59
  49. package/lib/ml-dom/node/parent-node.js +15 -6
  50. package/lib/ml-dom/node/rule-mapper.d.ts +9 -9
  51. package/lib/ml-dom/node/rule-mapper.js +11 -3
  52. package/lib/ml-dom/node/text.d.ts +50 -47
  53. package/lib/ml-dom/node/types.d.ts +94 -16
  54. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -2
  55. package/lib/ml-dom/token/token.d.ts +44 -44
  56. package/lib/ml-rule/create-rule.d.ts +4 -2
  57. package/lib/ml-rule/create-test-rule.d.ts +6 -4
  58. package/lib/ml-rule/ml-rule-context.d.ts +58 -49
  59. package/lib/ml-rule/ml-rule-context.js +23 -4
  60. package/lib/ml-rule/ml-rule.d.ts +36 -26
  61. package/lib/ml-rule/ml-rule.js +39 -34
  62. package/lib/ml-rule/types.d.ts +35 -17
  63. package/lib/plugin/plugin.d.ts +3 -1
  64. package/lib/plugin/types.d.ts +9 -9
  65. package/lib/ruleset/index.d.ts +4 -4
  66. package/lib/ruleset/index.js +4 -4
  67. package/lib/test/index.d.ts +21 -8
  68. package/lib/test/index.js +6 -4
  69. package/lib/types.d.ts +12 -10
  70. package/lib/utils/get-location-from-chars.d.ts +9 -4
  71. package/package.json +21 -15
  72. package/test/ml-dom/helper/accname.spec.js +85 -0
  73. package/test/ml-dom/helper/create-node.spec.js +18 -0
  74. package/test/ml-dom/index.spec.js +680 -0
  75. package/lib/ml-dom/document.d.ts +0 -94
  76. package/lib/ml-dom/document.js +0 -273
  77. package/lib/ml-dom/helper/index.d.ts +0 -4
  78. package/lib/ml-dom/helper/index.js +0 -12
  79. package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -52
  80. package/lib/ml-dom/helper/mapped-nodes.js +0 -2
  81. package/lib/ml-dom/helper/match-selector.d.ts +0 -20
  82. package/lib/ml-dom/helper/match-selector.js +0 -233
  83. package/lib/ml-dom/helper/node-store.d.ts +0 -12
  84. package/lib/ml-dom/helper/node-store.js +0 -28
  85. package/lib/ml-dom/helper/selector.d.ts +0 -11
  86. package/lib/ml-dom/helper/selector.js +0 -549
  87. package/lib/ml-dom/rule-mapper.d.ts +0 -16
  88. package/lib/ml-dom/rule-mapper.js +0 -57
  89. package/lib/ml-dom/tokens/abstract-element.d.ts +0 -54
  90. package/lib/ml-dom/tokens/abstract-element.js +0 -249
  91. package/lib/ml-dom/tokens/attribute.d.ts +0 -42
  92. package/lib/ml-dom/tokens/attribute.js +0 -85
  93. package/lib/ml-dom/tokens/comment.d.ts +0 -12
  94. package/lib/ml-dom/tokens/comment.js +0 -15
  95. package/lib/ml-dom/tokens/doctype.d.ts +0 -18
  96. package/lib/ml-dom/tokens/doctype.js +0 -32
  97. package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -27
  98. package/lib/ml-dom/tokens/element-close-tag.js +0 -45
  99. package/lib/ml-dom/tokens/element.d.ts +0 -26
  100. package/lib/ml-dom/tokens/element.js +0 -66
  101. package/lib/ml-dom/tokens/index.d.ts +0 -10
  102. package/lib/ml-dom/tokens/index.js +0 -26
  103. package/lib/ml-dom/tokens/node.d.ts +0 -46
  104. package/lib/ml-dom/tokens/node.js +0 -126
  105. package/lib/ml-dom/tokens/omitted-element.d.ts +0 -13
  106. package/lib/ml-dom/tokens/omitted-element.js +0 -12
  107. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
  108. package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
  109. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -14
  110. package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
  111. package/lib/ml-dom/tokens/text.d.ts +0 -19
  112. package/lib/ml-dom/tokens/text.js +0 -26
  113. package/lib/ml-dom/tokens/token.d.ts +0 -16
  114. package/lib/ml-dom/tokens/token.js +0 -55
  115. package/lib/ml-dom/types.d.ts +0 -49
  116. package/lib/ml-dom/types.js +0 -2
  117. package/lib/selector/is-pure-html-element.d.ts +0 -1
  118. package/lib/selector/is-pure-html-element.js +0 -7
  119. package/lib/selector/match-selector.d.ts +0 -14
  120. package/lib/selector/match-selector.js +0 -230
  121. package/lib/selector/selector.d.ts +0 -9
  122. package/lib/selector/selector.js +0 -561
  123. package/tsconfig.test.json +0 -3
  124. package/tsconfig.tsbuildinfo +0 -1
@@ -9,23 +9,10 @@ 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
- /**
15
- * Cached `childNodes` property
16
- */
17
- _MLNode_childNodes.set(this, void 0);
18
- /**
19
- * Owner `Document`
20
- *
21
- * @implements DOM API: `Node`
22
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument
23
- */
24
- _MLNode_ownerDocument.set(this, void 0);
25
- /**
26
- * Cached `prevToken` property
27
- */
28
- _MLNode_prevToken.set(this, void 0);
29
16
  /**
30
17
  * @implements DOM API: `Node`
31
18
  * @see https://dom.spec.whatwg.org/#interface-node
@@ -118,12 +105,30 @@ class MLNode extends token_1.MLToken {
118
105
  * @see https://dom.spec.whatwg.org/#interface-node
119
106
  */
120
107
  this.PROCESSING_INSTRUCTION_NODE = 7;
121
- this.rules = {};
122
108
  /**
123
109
  * @implements DOM API: `Node`
124
110
  * @see https://dom.spec.whatwg.org/#interface-node
125
111
  */
126
112
  this.TEXT_NODE = 3;
113
+ /**
114
+ * Cached `childNodes` property
115
+ */
116
+ _MLNode_childNodes.set(this, void 0);
117
+ /**
118
+ * Owner `Document`
119
+ *
120
+ * @implements DOM API: `Node`
121
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument
122
+ */
123
+ _MLNode_ownerDocument.set(this, void 0);
124
+ /**
125
+ * Cached `prevToken` property
126
+ */
127
+ _MLNode_prevToken.set(this, void 0);
128
+ /**
129
+ *
130
+ */
131
+ this.rules = {};
127
132
  this._astToken = astNode;
128
133
  tslib_1.__classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
129
134
  node_store_1.nodeStore.setNode(astNode, this);
@@ -146,6 +151,7 @@ class MLNode extends token_1.MLToken {
146
151
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-childnodes%E2%91%A0
147
152
  */
148
153
  get childNodes() {
154
+ var _a;
149
155
  if (tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f") != null) {
150
156
  return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
151
157
  }
@@ -164,7 +170,7 @@ class MLNode extends token_1.MLToken {
164
170
  this.is(this.ELEMENT_NODE) ||
165
171
  this.is(this.MARKUPLINT_PREPROCESSOR_BLOCK)) {
166
172
  // @ts-ignore
167
- const astChildren = this._astToken.childNodes || [];
173
+ const astChildren = (_a = this._astToken.childNodes) !== null && _a !== void 0 ? _a : [];
168
174
  const childNodes = astChildren
169
175
  .map(node => node_store_1.nodeStore.getNode(node))
170
176
  .filter((node) => (0, child_node_1.isChildNode)(node));
@@ -184,7 +190,8 @@ class MLNode extends token_1.MLToken {
184
190
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-firstchild%E2%91%A0
185
191
  */
186
192
  get firstChild() {
187
- return this.childNodes[0] || null;
193
+ var _a;
194
+ return (_a = this.childNodes[0]) !== null && _a !== void 0 ? _a : null;
188
195
  }
189
196
  /**
190
197
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -204,7 +211,8 @@ class MLNode extends token_1.MLToken {
204
211
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-lastchild%E2%91%A0
205
212
  */
206
213
  get lastChild() {
207
- 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;
208
216
  }
209
217
  /**
210
218
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -333,7 +341,7 @@ class MLNode extends token_1.MLToken {
333
341
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-parentnode%E2%91%A0
334
342
  */
335
343
  get parentNode() {
336
- const parentNode = this.syntaxicalParentNode;
344
+ const parentNode = this.syntacticalParentNode;
337
345
  if (!parentNode) {
338
346
  return null;
339
347
  }
@@ -351,16 +359,6 @@ class MLNode extends token_1.MLToken {
351
359
  }
352
360
  return parentNode;
353
361
  }
354
- /**
355
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
356
- *
357
- * @unsupported
358
- * @implements DOM API: `Node`
359
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
360
- */
361
- get previousSibling() {
362
- throw new unexpected_call_error_1.default('Not supported "previousSibling" property');
363
- }
364
362
  /**
365
363
  * @implements `@markuplint/ml-core` API: `MLNode`
366
364
  */
@@ -374,6 +372,7 @@ class MLNode extends token_1.MLToken {
374
372
  * @implements `@markuplint/ml-core` API: `MLNode`
375
373
  */
376
374
  get prevToken() {
375
+ var _a, _b;
377
376
  if (tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f") !== undefined) {
378
377
  return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
379
378
  }
@@ -395,8 +394,18 @@ class MLNode extends token_1.MLToken {
395
394
  tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
396
395
  return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
397
396
  }
398
- tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, this.ownerMLDocument.nodeList[index - 1] || null, "f");
399
- 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;
399
+ }
400
+ /**
401
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
402
+ *
403
+ * @unsupported
404
+ * @implements DOM API: `Node`
405
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
406
+ */
407
+ get previousSibling() {
408
+ throw new unexpected_call_error_1.default('Not supported "previousSibling" property');
400
409
  }
401
410
  /**
402
411
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -406,11 +415,16 @@ class MLNode extends token_1.MLToken {
406
415
  throw new Error('Invalid call: Some rule evaluations may not be running asynchronously.');
407
416
  }
408
417
  const name = this.ownerMLDocument.currentRule.name;
409
- const rule = this.rules[name];
410
- 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;
411
425
  }
412
426
  /**
413
- * Returns a syntaxical parent node
427
+ * Returns a syntactical parent node
414
428
  *
415
429
  * ## HTML:
416
430
  *
@@ -447,7 +461,7 @@ class MLNode extends token_1.MLToken {
447
461
  *
448
462
  * @implements `@markuplint/ml-core` API: `MLNode`
449
463
  */
450
- get syntaxicalParentNode() {
464
+ get syntacticalParentNode() {
451
465
  if (!this._astToken.parentNode) {
452
466
  return this.ownerMLDocument;
453
467
  }
@@ -472,7 +486,9 @@ class MLNode extends token_1.MLToken {
472
486
  * @implements DOM API: `EventTarget`
473
487
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-addeventlistener%E2%91%A2
474
488
  */
475
- addEventListener(type, callback, options = {}) {
489
+ addEventListener(type,
490
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
491
+ callback, options = {}) {
476
492
  throw new unexpected_call_error_1.default('Not supported "addEventListener" method');
477
493
  }
478
494
  /**
@@ -502,7 +518,9 @@ class MLNode extends token_1.MLToken {
502
518
  * @implements DOM API: `Node`
503
519
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-comparedocumentposition%E2%91%A0
504
520
  */
505
- compareDocumentPosition(other) {
521
+ compareDocumentPosition(
522
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
523
+ other) {
506
524
  throw new unexpected_call_error_1.default('Not supported "compareDocumentPosition" method');
507
525
  }
508
526
  /**
@@ -512,7 +530,9 @@ class MLNode extends token_1.MLToken {
512
530
  * @implements DOM API: `Node`
513
531
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-contains%E2%91%A0
514
532
  */
515
- contains(other) {
533
+ contains(
534
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
535
+ other) {
516
536
  throw new unexpected_call_error_1.default('Not supported "contains" method');
517
537
  }
518
538
  /**
@@ -522,7 +542,9 @@ class MLNode extends token_1.MLToken {
522
542
  * @implements DOM API: `EventTarget`
523
543
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-dispatchevent%E2%91%A2
524
544
  */
525
- dispatchEvent(event) {
545
+ dispatchEvent(
546
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
547
+ event) {
526
548
  throw new unexpected_call_error_1.default('Not supported "dispatchEvent" method');
527
549
  }
528
550
  /**
@@ -532,7 +554,9 @@ class MLNode extends token_1.MLToken {
532
554
  * @implements DOM API: `Node`
533
555
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-getrootnode%E2%91%A0
534
556
  */
535
- getRootNode(options) {
557
+ getRootNode(
558
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
559
+ options) {
536
560
  if (options) {
537
561
  throw new unexpected_call_error_1.default('Not supported options');
538
562
  }
@@ -556,7 +580,9 @@ class MLNode extends token_1.MLToken {
556
580
  * @implements DOM API: `Node`
557
581
  * @see https://dom.spec.whatwg.org/#dom-node-insertbefore
558
582
  */
559
- insertBefore(node, child) {
583
+ insertBefore(node,
584
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
585
+ child) {
560
586
  throw new unexpected_call_error_1.default('Not supported "insertBefore" method');
561
587
  }
562
588
  /**
@@ -582,7 +608,9 @@ class MLNode extends token_1.MLToken {
582
608
  * @implements DOM API: `Node`
583
609
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-isequalnode%E2%91%A0
584
610
  */
585
- isEqualNode(otherNode) {
611
+ isEqualNode(
612
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
613
+ otherNode) {
586
614
  throw new unexpected_call_error_1.default('Not supported "isEqualNode" method');
587
615
  }
588
616
  /**
@@ -598,7 +626,9 @@ class MLNode extends token_1.MLToken {
598
626
  * @implements DOM API: `Node`
599
627
  * @see https://dom.spec.whatwg.org/#dom-node-issamenode
600
628
  */
601
- isSameNode(otherNode) {
629
+ isSameNode(
630
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
631
+ otherNode) {
602
632
  throw new unexpected_call_error_1.default('Not supported "isSameNode" method');
603
633
  }
604
634
  /**
@@ -648,7 +678,9 @@ class MLNode extends token_1.MLToken {
648
678
  * @implements DOM API: `EventTarget`
649
679
  * @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-removeeventlistener%E2%91%A1
650
680
  */
651
- removeEventListener(type, callback, options = {}) {
681
+ removeEventListener(type,
682
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
683
+ callback, options = {}) {
652
684
  throw new unexpected_call_error_1.default('Not supported "removeEventListener" method');
653
685
  }
654
686
  /**
@@ -658,9 +690,19 @@ class MLNode extends token_1.MLToken {
658
690
  * @implements DOM API: `Node`
659
691
  * @see https://dom.spec.whatwg.org/#dom-node-replacechild
660
692
  */
661
- replaceChild(node, child) {
693
+ replaceChild(
694
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
695
+ node, child) {
662
696
  throw new unexpected_call_error_1.default('Not supported "removeChild" method');
663
697
  }
698
+ /**
699
+ * @implements `@markuplint/ml-core` API: `MLNode`
700
+ */
701
+ resetChildren(
702
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
703
+ childNodes) {
704
+ tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, childNodes !== null && childNodes !== void 0 ? childNodes : tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
705
+ }
664
706
  }
665
707
  exports.MLNode = MLNode;
666
708
  _MLNode_childNodes = new WeakMap(), _MLNode_ownerDocument = new WeakMap(), _MLNode_prevToken = new WeakMap();
@@ -1,66 +1,75 @@
1
1
  import type { MLElement } from './element';
2
- import type { MLASTAbstructNode } from '@markuplint/ml-ast';
3
- import type { RuleConfigValue } from '@markuplint/ml-config';
2
+ import type { MLASTAbstractNode } from '@markuplint/ml-ast';
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 MLASTAbstructNode = MLASTAbstructNode> 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) {
@@ -2,16 +2,16 @@ import type { MLDocument } from './document';
2
2
  import type { MLNode } from './node';
3
3
  import type { AnyRule } from '@markuplint/ml-config';
4
4
  import type { Specificity } from '@markuplint/selector';
5
- declare type RuleType = 'rules' | 'nodeRules' | 'childNodeRules';
6
- declare type MappingLayer = {
7
- from: RuleType;
8
- specificity: Specificity;
9
- rule: AnyRule;
5
+ type RuleType = 'rules' | 'nodeRules' | 'childNodeRules';
6
+ type MappingLayer = {
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
  }