@markuplint/ml-core 3.11.0 → 4.0.0-alpha.1

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 (95) hide show
  1. package/lib/configs.browser.js +1 -5
  2. package/lib/configs.js +33 -30
  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 +12 -12
  7. package/lib/index.js +13 -29
  8. package/lib/ml-core.d.ts +2 -2
  9. package/lib/ml-core.js +60 -66
  10. package/lib/ml-dom/helper/accname.d.ts +1 -1
  11. package/lib/ml-dom/helper/accname.js +9 -16
  12. package/lib/ml-dom/helper/create-node.d.ts +2 -2
  13. package/lib/ml-dom/helper/create-node.js +11 -15
  14. package/lib/ml-dom/helper/debug.d.ts +1 -1
  15. package/lib/ml-dom/helper/debug.js +2 -7
  16. package/lib/ml-dom/helper/getIndent.d.ts +2 -2
  17. package/lib/ml-dom/helper/getIndent.js +15 -19
  18. package/lib/ml-dom/helper/walkers.d.ts +1 -1
  19. package/lib/ml-dom/helper/walkers.js +2 -7
  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 +2 -2
  23. package/lib/ml-dom/manipulations/child-node-methods.js +13 -25
  24. package/lib/ml-dom/manipulations/get-children.d.ts +2 -2
  25. package/lib/ml-dom/manipulations/get-children.js +3 -7
  26. package/lib/ml-dom/node/attr.d.ts +5 -5
  27. package/lib/ml-dom/node/attr.js +28 -33
  28. package/lib/ml-dom/node/block.d.ts +4 -4
  29. package/lib/ml-dom/node/block.js +7 -11
  30. package/lib/ml-dom/node/character-data.d.ts +2 -2
  31. package/lib/ml-dom/node/character-data.js +11 -16
  32. package/lib/ml-dom/node/child-node.d.ts +6 -6
  33. package/lib/ml-dom/node/child-node.js +1 -5
  34. package/lib/ml-dom/node/comment.d.ts +2 -2
  35. package/lib/ml-dom/node/comment.js +2 -6
  36. package/lib/ml-dom/node/document-fragment.d.ts +2 -2
  37. package/lib/ml-dom/node/document-fragment.js +4 -9
  38. package/lib/ml-dom/node/document-type.d.ts +4 -4
  39. package/lib/ml-dom/node/document-type.js +7 -11
  40. package/lib/ml-dom/node/document.d.ts +13 -13
  41. package/lib/ml-dom/node/document.js +233 -241
  42. package/lib/ml-dom/node/dom-token-list.d.ts +1 -1
  43. package/lib/ml-dom/node/dom-token-list.js +25 -31
  44. package/lib/ml-dom/node/element.d.ts +8 -8
  45. package/lib/ml-dom/node/element.js +278 -296
  46. package/lib/ml-dom/node/named-node-map.d.ts +1 -1
  47. package/lib/ml-dom/node/named-node-map.js +10 -18
  48. package/lib/ml-dom/node/node-list.d.ts +2 -2
  49. package/lib/ml-dom/node/node-list.js +6 -14
  50. package/lib/ml-dom/node/node-store.d.ts +2 -2
  51. package/lib/ml-dom/node/node-store.js +9 -12
  52. package/lib/ml-dom/node/node.d.ts +8 -8
  53. package/lib/ml-dom/node/node.js +58 -66
  54. package/lib/ml-dom/node/parent-node.d.ts +2 -2
  55. package/lib/ml-dom/node/parent-node.js +22 -29
  56. package/lib/ml-dom/node/rule-mapper.d.ts +2 -2
  57. package/lib/ml-dom/node/rule-mapper.js +11 -16
  58. package/lib/ml-dom/node/text.d.ts +2 -2
  59. package/lib/ml-dom/node/text.js +6 -11
  60. package/lib/ml-dom/node/types.d.ts +10 -10
  61. package/lib/ml-dom/node/types.js +1 -2
  62. package/lib/ml-dom/node/unexpected-call-error.js +1 -4
  63. package/lib/ml-dom/token/token.js +19 -23
  64. package/lib/ml-rule/create-rule.d.ts +1 -1
  65. package/lib/ml-rule/create-rule.js +1 -5
  66. package/lib/ml-rule/create-test-rule.d.ts +2 -2
  67. package/lib/ml-rule/create-test-rule.js +3 -7
  68. package/lib/ml-rule/index.d.ts +3 -3
  69. package/lib/ml-rule/index.js +3 -6
  70. package/lib/ml-rule/ml-rule-context.d.ts +2 -2
  71. package/lib/ml-rule/ml-rule-context.js +7 -11
  72. package/lib/ml-rule/ml-rule.d.ts +3 -3
  73. package/lib/ml-rule/ml-rule.js +23 -30
  74. package/lib/ml-rule/types.d.ts +2 -2
  75. package/lib/ml-rule/types.js +1 -2
  76. package/lib/plugin/index.d.ts +2 -2
  77. package/lib/plugin/index.js +2 -5
  78. package/lib/plugin/plugin.d.ts +1 -1
  79. package/lib/plugin/plugin.js +1 -5
  80. package/lib/plugin/types.d.ts +1 -1
  81. package/lib/plugin/types.js +1 -2
  82. package/lib/ruleset/index.js +4 -8
  83. package/lib/test/index.d.ts +4 -4
  84. package/lib/test/index.js +13 -23
  85. package/lib/types.d.ts +2 -2
  86. package/lib/types.js +1 -2
  87. package/lib/utils/get-location-from-chars.js +1 -5
  88. package/lib/utils/index.d.ts +1 -1
  89. package/lib/utils/index.js +1 -5
  90. package/lib/utils/string-splice.js +1 -5
  91. package/package.json +20 -15
  92. package/test/ml-dom/helper/accname.spec.js +0 -85
  93. package/test/ml-dom/helper/create-node.spec.js +0 -18
  94. package/test/ml-dom/index.spec.js +0 -680
  95. package/test/ml-dom/ml-rule/create-rule.spec.js +0 -108
@@ -1,4 +1,4 @@
1
- import type { MLAttr } from './attr';
1
+ import type { MLAttr } from './attr.js';
2
2
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
3
3
  export declare class MLNamedNodeMap<T extends RuleConfigValue, O extends PlainData = undefined> extends Array<MLAttr<T, O>> implements NamedNodeMap {
4
4
  getNamedItem(qualifiedName: string): MLAttr<T, O> | null;
@@ -1,12 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toNamedNodeMap = exports.MLNamedNodeMap = void 0;
4
- const tslib_1 = require("tslib");
5
- const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
6
- class MLNamedNodeMap extends Array {
1
+ import UnexpectedCallError from './unexpected-call-error.js';
2
+ export class MLNamedNodeMap extends Array {
7
3
  getNamedItem(qualifiedName) {
8
- var _a;
9
- return (_a = this.find(attr => attr.name === qualifiedName)) !== null && _a !== void 0 ? _a : null;
4
+ return this.find(attr => attr.name === qualifiedName) ?? null;
10
5
  }
11
6
  /**
12
7
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -15,11 +10,10 @@ class MLNamedNodeMap extends Array {
15
10
  * @implements DOM API: `NamedNodeMap`
16
11
  */
17
12
  getNamedItemNS(namespace, localName) {
18
- throw new unexpected_call_error_1.default('Not supported "getNamedItemNS" method');
13
+ throw new UnexpectedCallError('Not supported "getNamedItemNS" method');
19
14
  }
20
15
  item(index) {
21
- var _a;
22
- return (_a = this[index]) !== null && _a !== void 0 ? _a : null;
16
+ return this[index] ?? null;
23
17
  }
24
18
  /**
25
19
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -28,7 +22,7 @@ class MLNamedNodeMap extends Array {
28
22
  * @implements DOM API: `NamedNodeMap`
29
23
  */
30
24
  removeNamedItem(qualifiedName) {
31
- throw new unexpected_call_error_1.default('Not supported "removeNamedItem" method');
25
+ throw new UnexpectedCallError('Not supported "removeNamedItem" method');
32
26
  }
33
27
  /**
34
28
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -37,7 +31,7 @@ class MLNamedNodeMap extends Array {
37
31
  * @implements DOM API: `NamedNodeMap`
38
32
  */
39
33
  removeNamedItemNS(namespace, localName) {
40
- throw new unexpected_call_error_1.default('Not supported "removeNamedItemNS" method');
34
+ throw new UnexpectedCallError('Not supported "removeNamedItemNS" method');
41
35
  }
42
36
  /**
43
37
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -48,7 +42,7 @@ class MLNamedNodeMap extends Array {
48
42
  setNamedItem(
49
43
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
50
44
  attr) {
51
- throw new unexpected_call_error_1.default('Not supported "setNamedItem" method');
45
+ throw new UnexpectedCallError('Not supported "setNamedItem" method');
52
46
  }
53
47
  /**
54
48
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -59,14 +53,12 @@ class MLNamedNodeMap extends Array {
59
53
  setNamedItemNS(
60
54
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
61
55
  attr) {
62
- throw new unexpected_call_error_1.default('Not supported "setNamedItemNS" method');
56
+ throw new UnexpectedCallError('Not supported "setNamedItemNS" method');
63
57
  }
64
58
  }
65
- exports.MLNamedNodeMap = MLNamedNodeMap;
66
- function toNamedNodeMap(
59
+ export function toNamedNodeMap(
67
60
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
68
61
  nodes) {
69
62
  const namedNodeMap = new MLNamedNodeMap(...nodes);
70
63
  return namedNodeMap;
71
64
  }
72
- exports.toNamedNodeMap = toNamedNodeMap;
@@ -1,5 +1,5 @@
1
- import type { MLChildNode } from './child-node';
2
- import type { MLElement } from './element';
1
+ import type { MLChildNode } from './child-node.js';
2
+ import type { MLElement } from './element.js';
3
3
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  export declare function toNodeList<T extends RuleConfigValue, O extends PlainData, N extends MLChildNode<T, O>>(nodes: ReadonlyArray<N>): NodeListOf<N>;
5
5
  export declare function toHTMLCollection<T extends RuleConfigValue, O extends PlainData = undefined>(nodes: ReadonlyArray<MLElement<T, O>>): HTMLCollectionOf<MLElement<T, O>>;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nodeListToHTMLCollection = exports.toHTMLCollection = exports.toNodeList = void 0;
4
1
  class MLNodeList extends Array {
5
2
  forEach(callbackfn, thisArg) {
6
- return super.forEach.bind(this)((v, k) => callbackfn(v, k, thisArg !== null && thisArg !== void 0 ? thisArg : this));
3
+ return super.forEach.bind(this)((v, k) => callbackfn(v, k, thisArg ?? this));
7
4
  }
8
5
  item(index) {
9
6
  const node = this[index];
@@ -23,29 +20,25 @@ class MLNodeList extends Array {
23
20
  return node;
24
21
  }
25
22
  }
26
- function toNodeList(nodes) {
23
+ export function toNodeList(nodes) {
27
24
  const nodeList = new MLNodeList(...nodes);
28
25
  return nodeList;
29
26
  }
30
- exports.toNodeList = toNodeList;
31
27
  class MLHTMLCollection extends Array {
32
28
  item(index) {
33
- var _a;
34
- return (_a = this[index]) !== null && _a !== void 0 ? _a : null;
29
+ return this[index] ?? null;
35
30
  }
36
31
  namedItem(name) {
37
- var _a;
38
- return (_a = this.find(el => el.getAttribute('name') === name)) !== null && _a !== void 0 ? _a : null;
32
+ return this.find(el => el.getAttribute('name') === name) ?? null;
39
33
  }
40
34
  }
41
- function toHTMLCollection(
35
+ export function toHTMLCollection(
42
36
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
43
37
  nodes) {
44
38
  const collection = new MLHTMLCollection(...nodes);
45
39
  return collection;
46
40
  }
47
- exports.toHTMLCollection = toHTMLCollection;
48
- function nodeListToHTMLCollection(
41
+ export function nodeListToHTMLCollection(
49
42
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
50
43
  nodeList) {
51
44
  const collection = new MLHTMLCollection();
@@ -56,4 +49,3 @@ nodeList) {
56
49
  });
57
50
  return collection;
58
51
  }
59
- exports.nodeListToHTMLCollection = nodeListToHTMLCollection;
@@ -1,5 +1,5 @@
1
- import type { MLNode } from './node';
2
- import type { MappedNode } from './types';
1
+ import type { MLNode } from './node.js';
2
+ import type { MappedNode } from './types.js';
3
3
  import type { MLASTAbstractNode } from '@markuplint/ml-ast';
4
4
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
5
5
  declare class NodeStore {
@@ -1,11 +1,8 @@
1
- "use strict";
2
1
  var _NodeStore_store;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.nodeStore = void 0;
5
- const tslib_1 = require("tslib");
6
- const parser_utils_1 = require("@markuplint/parser-utils");
7
- const debug_1 = require("../../debug");
8
- const nodeStoreLog = debug_1.log.extend('node-store');
2
+ import { __classPrivateFieldGet } from "tslib";
3
+ import { TargetParserError } from '@markuplint/parser-utils';
4
+ import { log } from '../../debug.js';
5
+ const nodeStoreLog = log.extend('node-store');
9
6
  const nodeStoreError = nodeStoreLog.extend('error');
10
7
  class NodeStore {
11
8
  constructor() {
@@ -13,14 +10,14 @@ class NodeStore {
13
10
  }
14
11
  getNode(astNode) {
15
12
  // console.log(`Get: ${astNode.uuid} -> ${astNode.raw.trim()}(${astNode.type})`);
16
- const node = tslib_1.__classPrivateFieldGet(this, _NodeStore_store, "f").get(astNode.uuid);
13
+ const node = __classPrivateFieldGet(this, _NodeStore_store, "f").get(astNode.uuid);
17
14
  if (!node) {
18
15
  nodeStoreError('Ref ID: %s (%s: "%s")', astNode.uuid, astNode.nodeName, astNode.raw);
19
- nodeStoreError('Map: %O', Array.from(tslib_1.__classPrivateFieldGet(this, _NodeStore_store, "f").entries()).map(([id, node]) => ({
16
+ nodeStoreError('Map: %O', Array.from(__classPrivateFieldGet(this, _NodeStore_store, "f").entries()).map(([id, node]) => ({
20
17
  id,
21
18
  name: node.nodeName,
22
19
  })));
23
- throw new parser_utils_1.TargetParserError('Broke mapping nodes.', {
20
+ throw new TargetParserError('Broke mapping nodes.', {
24
21
  line: astNode.startLine,
25
22
  col: astNode.startCol,
26
23
  raw: astNode.raw,
@@ -40,11 +37,11 @@ class NodeStore {
40
37
  nodeStoreError('Invalid node: %O', node);
41
38
  }
42
39
  nodeStoreLog('Mapped: %s (%s: "%s")', astNode.uuid, astNode.nodeName, astNode.raw.replace(/\n/g, '⏎').replace(/\t/g, '→'));
43
- tslib_1.__classPrivateFieldGet(this, _NodeStore_store, "f").set(astNode.uuid, node);
40
+ __classPrivateFieldGet(this, _NodeStore_store, "f").set(astNode.uuid, node);
44
41
  }
45
42
  }
46
43
  _NodeStore_store = new WeakMap();
47
44
  /**
48
45
  * `NodeStore` Singleton
49
46
  */
50
- exports.nodeStore = new NodeStore();
47
+ export const nodeStore = new NodeStore();
@@ -1,13 +1,13 @@
1
- import type { MLBlock } from './block';
2
- import type { MLChildNode } from './child-node';
3
- import type { MLDocument } from './document';
4
- import type { MLDocumentFragment } from './document-fragment';
5
- import type { MLElement } from './element';
6
- import type { MarkuplintPreprocessorBlockType, NodeType, NodeTypeOf } from './types';
7
- import type { RuleInfo } from '../..';
1
+ import type { MLBlock } from './block.js';
2
+ import type { MLChildNode } from './child-node.js';
3
+ import type { MLDocumentFragment } from './document-fragment.js';
4
+ import type { MLDocument } from './document.js';
5
+ import type { MLElement } from './element.js';
6
+ import type { MarkuplintPreprocessorBlockType, NodeType, NodeTypeOf } from './types.js';
7
+ import type { RuleInfo } from '../../index.js';
8
8
  import type { MLASTAbstractNode } from '@markuplint/ml-ast';
9
9
  import type { AnyRule, PlainData, RuleConfigValue } from '@markuplint/ml-config';
10
- import { MLToken } from '../token/token';
10
+ import { MLToken } from '../token/token.js';
11
11
  export declare abstract class MLNode<T extends RuleConfigValue, O extends PlainData = undefined, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLToken<A> implements Node {
12
12
  #private;
13
13
  /**
@@ -1,14 +1,11 @@
1
- "use strict";
2
1
  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 {
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { MLToken } from '../token/token.js';
4
+ import { isChildNode } from './child-node.js';
5
+ import { toNodeList } from './node-list.js';
6
+ import { nodeStore } from './node-store.js';
7
+ import UnexpectedCallError from './unexpected-call-error.js';
8
+ export class MLNode extends MLToken {
12
9
  constructor(astNode,
13
10
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
14
11
  document) {
@@ -130,8 +127,8 @@ class MLNode extends token_1.MLToken {
130
127
  */
131
128
  this.rules = {};
132
129
  this._astToken = astNode;
133
- tslib_1.__classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
134
- node_store_1.nodeStore.setNode(astNode, this);
130
+ __classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
131
+ nodeStore.setNode(astNode, this);
135
132
  }
136
133
  /**
137
134
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -141,7 +138,7 @@ class MLNode extends token_1.MLToken {
141
138
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-baseuri%E2%91%A0
142
139
  */
143
140
  get baseURI() {
144
- throw new unexpected_call_error_1.default('Not supported "baseURI" property');
141
+ throw new UnexpectedCallError('Not supported "baseURI" property');
145
142
  }
146
143
  /**
147
144
  * The list of child nodes that contains `Element`, `Text`, and `Comment`.
@@ -151,36 +148,35 @@ class MLNode extends token_1.MLToken {
151
148
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-childnodes%E2%91%A0
152
149
  */
153
150
  get childNodes() {
154
- var _a;
155
- if (tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f") != null) {
156
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
151
+ if (__classPrivateFieldGet(this, _MLNode_childNodes, "f") != null) {
152
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
157
153
  }
158
154
  if (this.is(this.DOCUMENT_NODE)) {
159
155
  const childNodes = [];
160
156
  for (const node of this.nodeList) {
161
- if ((0, child_node_1.isChildNode)(node) && (node.parentNode === this || node.parentNode === null)) {
157
+ if (isChildNode(node) && (node.parentNode === this || node.parentNode === null)) {
162
158
  childNodes.push(node);
163
159
  }
164
160
  }
165
161
  // Cache
166
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)(childNodes), "f");
167
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
162
+ __classPrivateFieldSet(this, _MLNode_childNodes, toNodeList(childNodes), "f");
163
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
168
164
  }
169
165
  if (this.is(this.DOCUMENT_FRAGMENT_NODE) ||
170
166
  this.is(this.ELEMENT_NODE) ||
171
167
  this.is(this.MARKUPLINT_PREPROCESSOR_BLOCK)) {
172
168
  // @ts-ignore
173
- const astChildren = (_a = this._astToken.childNodes) !== null && _a !== void 0 ? _a : [];
169
+ const astChildren = this._astToken.childNodes ?? [];
174
170
  const childNodes = astChildren
175
- .map(node => node_store_1.nodeStore.getNode(node))
176
- .filter((node) => (0, child_node_1.isChildNode)(node));
171
+ .map(node => nodeStore.getNode(node))
172
+ .filter((node) => isChildNode(node));
177
173
  // Cache
178
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)(childNodes), "f");
179
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
174
+ __classPrivateFieldSet(this, _MLNode_childNodes, toNodeList(childNodes), "f");
175
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
180
176
  }
181
177
  // Cache
182
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)([]), "f");
183
- return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
178
+ __classPrivateFieldSet(this, _MLNode_childNodes, toNodeList([]), "f");
179
+ return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
184
180
  }
185
181
  /**
186
182
  * The first node that may be `Element`, `Text`, and `CommentNode`.
@@ -190,8 +186,7 @@ class MLNode extends token_1.MLToken {
190
186
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-firstchild%E2%91%A0
191
187
  */
192
188
  get firstChild() {
193
- var _a;
194
- return (_a = this.childNodes[0]) !== null && _a !== void 0 ? _a : null;
189
+ return this.childNodes[0] ?? null;
195
190
  }
196
191
  /**
197
192
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -201,7 +196,7 @@ class MLNode extends token_1.MLToken {
201
196
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-isconnected%E2%91%A0
202
197
  */
203
198
  get isConnected() {
204
- throw new unexpected_call_error_1.default('Not supported "isConnected" property');
199
+ throw new UnexpectedCallError('Not supported "isConnected" property');
205
200
  }
206
201
  /**
207
202
  * The last node that may be `Element`, `Text`, and `CommentNode`.
@@ -211,8 +206,7 @@ class MLNode extends token_1.MLToken {
211
206
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-lastchild%E2%91%A0
212
207
  */
213
208
  get lastChild() {
214
- var _a;
215
- return (_a = this.childNodes[this.childNodes.length - 1]) !== null && _a !== void 0 ? _a : null;
209
+ return this.childNodes[this.childNodes.length - 1] ?? null;
216
210
  }
217
211
  /**
218
212
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -221,7 +215,7 @@ class MLNode extends token_1.MLToken {
221
215
  if (!this._astToken.nextNode) {
222
216
  return null;
223
217
  }
224
- return node_store_1.nodeStore.getNode(this._astToken.nextNode);
218
+ return nodeStore.getNode(this._astToken.nextNode);
225
219
  }
226
220
  /**
227
221
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -231,7 +225,7 @@ class MLNode extends token_1.MLToken {
231
225
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-nextsibling%E2%91%A0
232
226
  */
233
227
  get nextSibling() {
234
- throw new unexpected_call_error_1.default('Not supported "nextSibling" property');
228
+ throw new UnexpectedCallError('Not supported "nextSibling" property');
235
229
  }
236
230
  /**
237
231
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -272,10 +266,10 @@ class MLNode extends token_1.MLToken {
272
266
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument%E2%91%A0
273
267
  */
274
268
  get ownerDocument() {
275
- return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
269
+ return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
276
270
  }
277
271
  get ownerMLDocument() {
278
- return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
272
+ return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
279
273
  }
280
274
  /**
281
275
  * The parent element.
@@ -366,15 +360,14 @@ class MLNode extends token_1.MLToken {
366
360
  if (!this._astToken.prevNode) {
367
361
  return null;
368
362
  }
369
- return node_store_1.nodeStore.getNode(this._astToken.prevNode);
363
+ return nodeStore.getNode(this._astToken.prevNode);
370
364
  }
371
365
  /**
372
366
  * @implements `@markuplint/ml-core` API: `MLNode`
373
367
  */
374
368
  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");
369
+ if (__classPrivateFieldGet(this, _MLNode_prevToken, "f") !== undefined) {
370
+ return __classPrivateFieldGet(this, _MLNode_prevToken, "f");
378
371
  }
379
372
  let index = -1;
380
373
  for (let i = 0; i < this.ownerMLDocument.nodeList.length; i++) {
@@ -391,11 +384,11 @@ class MLNode extends token_1.MLToken {
391
384
  }
392
385
  }
393
386
  if (index === -1) {
394
- tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
395
- return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
387
+ __classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
388
+ return __classPrivateFieldGet(this, _MLNode_prevToken, "f");
396
389
  }
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;
390
+ __classPrivateFieldSet(this, _MLNode_prevToken, this.ownerMLDocument.nodeList[index - 1] ?? null, "f");
391
+ return __classPrivateFieldGet(this, _MLNode_prevToken, "f") ?? null;
399
392
  }
400
393
  /**
401
394
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -405,7 +398,7 @@ class MLNode extends token_1.MLToken {
405
398
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
406
399
  */
407
400
  get previousSibling() {
408
- throw new unexpected_call_error_1.default('Not supported "previousSibling" property');
401
+ throw new UnexpectedCallError('Not supported "previousSibling" property');
409
402
  }
410
403
  /**
411
404
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -465,7 +458,7 @@ class MLNode extends token_1.MLToken {
465
458
  if (!this._astToken.parentNode) {
466
459
  return this.ownerMLDocument;
467
460
  }
468
- return node_store_1.nodeStore.getNode(this._astToken.parentNode);
461
+ return nodeStore.getNode(this._astToken.parentNode);
469
462
  }
470
463
  /**
471
464
  * Return the text content.
@@ -489,7 +482,7 @@ class MLNode extends token_1.MLToken {
489
482
  addEventListener(type,
490
483
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
491
484
  callback, options = {}) {
492
- throw new unexpected_call_error_1.default('Not supported "addEventListener" method');
485
+ throw new UnexpectedCallError('Not supported "addEventListener" method');
493
486
  }
494
487
  /**
495
488
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -499,7 +492,7 @@ class MLNode extends token_1.MLToken {
499
492
  * @see https://dom.spec.whatwg.org/#dom-node-appendchild
500
493
  */
501
494
  appendChild(node) {
502
- throw new unexpected_call_error_1.default('Not supported "appendChild" method');
495
+ throw new UnexpectedCallError('Not supported "appendChild" method');
503
496
  }
504
497
  /**
505
498
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -509,7 +502,7 @@ class MLNode extends token_1.MLToken {
509
502
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-clonenode%E2%91%A0
510
503
  */
511
504
  cloneNode(deep) {
512
- throw new unexpected_call_error_1.default('Not supported "appendChild" method');
505
+ throw new UnexpectedCallError('Not supported "appendChild" method');
513
506
  }
514
507
  /**
515
508
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -521,7 +514,7 @@ class MLNode extends token_1.MLToken {
521
514
  compareDocumentPosition(
522
515
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
523
516
  other) {
524
- throw new unexpected_call_error_1.default('Not supported "compareDocumentPosition" method');
517
+ throw new UnexpectedCallError('Not supported "compareDocumentPosition" method');
525
518
  }
526
519
  /**
527
520
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -533,7 +526,7 @@ class MLNode extends token_1.MLToken {
533
526
  contains(
534
527
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
535
528
  other) {
536
- throw new unexpected_call_error_1.default('Not supported "contains" method');
529
+ throw new UnexpectedCallError('Not supported "contains" method');
537
530
  }
538
531
  /**
539
532
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -545,7 +538,7 @@ class MLNode extends token_1.MLToken {
545
538
  dispatchEvent(
546
539
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
547
540
  event) {
548
- throw new unexpected_call_error_1.default('Not supported "dispatchEvent" method');
541
+ throw new UnexpectedCallError('Not supported "dispatchEvent" method');
549
542
  }
550
543
  /**
551
544
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -558,10 +551,10 @@ class MLNode extends token_1.MLToken {
558
551
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
559
552
  options) {
560
553
  if (options) {
561
- throw new unexpected_call_error_1.default('Not supported options');
554
+ throw new UnexpectedCallError('Not supported options');
562
555
  }
563
556
  // The original DOM API returns a document fragment if the element is a fragment.
564
- return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
557
+ return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
565
558
  }
566
559
  /**
567
560
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -571,7 +564,7 @@ class MLNode extends token_1.MLToken {
571
564
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-haschildnodes%E2%91%A0
572
565
  */
573
566
  hasChildNodes() {
574
- throw new unexpected_call_error_1.default('Not supported "hasChildNodes" method');
567
+ throw new UnexpectedCallError('Not supported "hasChildNodes" method');
575
568
  }
576
569
  /**
577
570
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -583,7 +576,7 @@ class MLNode extends token_1.MLToken {
583
576
  insertBefore(node,
584
577
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
585
578
  child) {
586
- throw new unexpected_call_error_1.default('Not supported "insertBefore" method');
579
+ throw new UnexpectedCallError('Not supported "insertBefore" method');
587
580
  }
588
581
  /**
589
582
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -599,7 +592,7 @@ class MLNode extends token_1.MLToken {
599
592
  * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
600
593
  */
601
594
  isDefaultNamespace(namespace) {
602
- throw new unexpected_call_error_1.default('Not supported "isDefaultNamespace" method');
595
+ throw new UnexpectedCallError('Not supported "isDefaultNamespace" method');
603
596
  }
604
597
  /**
605
598
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -611,7 +604,7 @@ class MLNode extends token_1.MLToken {
611
604
  isEqualNode(
612
605
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
613
606
  otherNode) {
614
- throw new unexpected_call_error_1.default('Not supported "isEqualNode" method');
607
+ throw new UnexpectedCallError('Not supported "isEqualNode" method');
615
608
  }
616
609
  /**
617
610
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -629,7 +622,7 @@ class MLNode extends token_1.MLToken {
629
622
  isSameNode(
630
623
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
631
624
  otherNode) {
632
- throw new unexpected_call_error_1.default('Not supported "isSameNode" method');
625
+ throw new UnexpectedCallError('Not supported "isSameNode" method');
633
626
  }
634
627
  /**
635
628
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -639,7 +632,7 @@ class MLNode extends token_1.MLToken {
639
632
  * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
640
633
  */
641
634
  lookupNamespaceURI(prefix) {
642
- throw new unexpected_call_error_1.default('Not supported "lookupNamespaceURI" method');
635
+ throw new UnexpectedCallError('Not supported "lookupNamespaceURI" method');
643
636
  }
644
637
  /**
645
638
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -649,7 +642,7 @@ class MLNode extends token_1.MLToken {
649
642
  * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
650
643
  */
651
644
  lookupPrefix(namespace) {
652
- throw new unexpected_call_error_1.default('Not supported "lookupPrefix" method');
645
+ throw new UnexpectedCallError('Not supported "lookupPrefix" method');
653
646
  }
654
647
  /**
655
648
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -659,7 +652,7 @@ class MLNode extends token_1.MLToken {
659
652
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-normalize%E2%91%A0
660
653
  */
661
654
  normalize() {
662
- throw new unexpected_call_error_1.default('Not supported "normalize" method');
655
+ throw new UnexpectedCallError('Not supported "normalize" method');
663
656
  }
664
657
  /**
665
658
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -669,7 +662,7 @@ class MLNode extends token_1.MLToken {
669
662
  * @see https://dom.spec.whatwg.org/#dom-node-removechild
670
663
  */
671
664
  removeChild(child) {
672
- throw new unexpected_call_error_1.default('Not supported "removeChild" method');
665
+ throw new UnexpectedCallError('Not supported "removeChild" method');
673
666
  }
674
667
  /**
675
668
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -681,7 +674,7 @@ class MLNode extends token_1.MLToken {
681
674
  removeEventListener(type,
682
675
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
683
676
  callback, options = {}) {
684
- throw new unexpected_call_error_1.default('Not supported "removeEventListener" method');
677
+ throw new UnexpectedCallError('Not supported "removeEventListener" method');
685
678
  }
686
679
  /**
687
680
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -693,7 +686,7 @@ class MLNode extends token_1.MLToken {
693
686
  replaceChild(
694
687
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
695
688
  node, child) {
696
- throw new unexpected_call_error_1.default('Not supported "removeChild" method');
689
+ throw new UnexpectedCallError('Not supported "removeChild" method');
697
690
  }
698
691
  /**
699
692
  * @implements `@markuplint/ml-core` API: `MLNode`
@@ -701,8 +694,7 @@ class MLNode extends token_1.MLToken {
701
694
  resetChildren(
702
695
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
703
696
  childNodes) {
704
- tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, childNodes !== null && childNodes !== void 0 ? childNodes : tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
697
+ __classPrivateFieldSet(this, _MLNode_childNodes, childNodes ?? __classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
705
698
  }
706
699
  }
707
- exports.MLNode = MLNode;
708
700
  _MLNode_childNodes = new WeakMap(), _MLNode_ownerDocument = new WeakMap(), _MLNode_prevToken = new WeakMap();
@@ -1,7 +1,7 @@
1
- import type { MLElement } from './element';
1
+ import type { MLElement } from './element.js';
2
2
  import type { MLASTAbstractNode } 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