@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.
- package/lib/configs.browser.js +1 -5
- package/lib/configs.js +33 -30
- package/lib/convert-ruleset.d.ts +1 -1
- package/lib/convert-ruleset.js +3 -8
- package/lib/debug.js +9 -14
- package/lib/index.d.ts +12 -12
- package/lib/index.js +13 -29
- package/lib/ml-core.d.ts +2 -2
- package/lib/ml-core.js +60 -66
- package/lib/ml-dom/helper/accname.d.ts +1 -1
- package/lib/ml-dom/helper/accname.js +9 -16
- package/lib/ml-dom/helper/create-node.d.ts +2 -2
- package/lib/ml-dom/helper/create-node.js +11 -15
- package/lib/ml-dom/helper/debug.d.ts +1 -1
- package/lib/ml-dom/helper/debug.js +2 -7
- package/lib/ml-dom/helper/getIndent.d.ts +2 -2
- package/lib/ml-dom/helper/getIndent.js +15 -19
- package/lib/ml-dom/helper/walkers.d.ts +1 -1
- package/lib/ml-dom/helper/walkers.js +2 -7
- package/lib/ml-dom/index.d.ts +9 -9
- package/lib/ml-dom/index.js +1 -5
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +2 -2
- package/lib/ml-dom/manipulations/child-node-methods.js +13 -25
- package/lib/ml-dom/manipulations/get-children.d.ts +2 -2
- package/lib/ml-dom/manipulations/get-children.js +3 -7
- package/lib/ml-dom/node/attr.d.ts +5 -5
- package/lib/ml-dom/node/attr.js +28 -33
- package/lib/ml-dom/node/block.d.ts +4 -4
- package/lib/ml-dom/node/block.js +7 -11
- package/lib/ml-dom/node/character-data.d.ts +2 -2
- package/lib/ml-dom/node/character-data.js +11 -16
- package/lib/ml-dom/node/child-node.d.ts +6 -6
- package/lib/ml-dom/node/child-node.js +1 -5
- package/lib/ml-dom/node/comment.d.ts +2 -2
- package/lib/ml-dom/node/comment.js +2 -6
- package/lib/ml-dom/node/document-fragment.d.ts +2 -2
- package/lib/ml-dom/node/document-fragment.js +4 -9
- package/lib/ml-dom/node/document-type.d.ts +4 -4
- package/lib/ml-dom/node/document-type.js +7 -11
- package/lib/ml-dom/node/document.d.ts +13 -13
- package/lib/ml-dom/node/document.js +233 -241
- package/lib/ml-dom/node/dom-token-list.d.ts +1 -1
- package/lib/ml-dom/node/dom-token-list.js +25 -31
- package/lib/ml-dom/node/element.d.ts +8 -8
- package/lib/ml-dom/node/element.js +278 -296
- package/lib/ml-dom/node/named-node-map.d.ts +1 -1
- package/lib/ml-dom/node/named-node-map.js +10 -18
- package/lib/ml-dom/node/node-list.d.ts +2 -2
- package/lib/ml-dom/node/node-list.js +6 -14
- package/lib/ml-dom/node/node-store.d.ts +2 -2
- package/lib/ml-dom/node/node-store.js +9 -12
- package/lib/ml-dom/node/node.d.ts +8 -8
- package/lib/ml-dom/node/node.js +58 -66
- package/lib/ml-dom/node/parent-node.d.ts +2 -2
- package/lib/ml-dom/node/parent-node.js +22 -29
- package/lib/ml-dom/node/rule-mapper.d.ts +2 -2
- package/lib/ml-dom/node/rule-mapper.js +11 -16
- package/lib/ml-dom/node/text.d.ts +2 -2
- package/lib/ml-dom/node/text.js +6 -11
- package/lib/ml-dom/node/types.d.ts +10 -10
- package/lib/ml-dom/node/types.js +1 -2
- package/lib/ml-dom/node/unexpected-call-error.js +1 -4
- package/lib/ml-dom/token/token.js +19 -23
- package/lib/ml-rule/create-rule.d.ts +1 -1
- package/lib/ml-rule/create-rule.js +1 -5
- package/lib/ml-rule/create-test-rule.d.ts +2 -2
- package/lib/ml-rule/create-test-rule.js +3 -7
- package/lib/ml-rule/index.d.ts +3 -3
- package/lib/ml-rule/index.js +3 -6
- package/lib/ml-rule/ml-rule-context.d.ts +2 -2
- package/lib/ml-rule/ml-rule-context.js +7 -11
- package/lib/ml-rule/ml-rule.d.ts +3 -3
- package/lib/ml-rule/ml-rule.js +23 -30
- package/lib/ml-rule/types.d.ts +2 -2
- package/lib/ml-rule/types.js +1 -2
- package/lib/plugin/index.d.ts +2 -2
- package/lib/plugin/index.js +2 -5
- package/lib/plugin/plugin.d.ts +1 -1
- package/lib/plugin/plugin.js +1 -5
- package/lib/plugin/types.d.ts +1 -1
- package/lib/plugin/types.js +1 -2
- package/lib/ruleset/index.js +4 -8
- package/lib/test/index.d.ts +4 -4
- package/lib/test/index.js +13 -23
- package/lib/types.d.ts +2 -2
- package/lib/types.js +1 -2
- package/lib/utils/get-location-from-chars.js +1 -5
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -5
- package/lib/utils/string-splice.js +1 -5
- package/package.json +20 -15
- package/test/ml-dom/helper/accname.spec.js +0 -85
- package/test/ml-dom/helper/create-node.spec.js +0 -18
- package/test/ml-dom/index.spec.js +0 -680
- 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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
|
13
|
+
throw new UnexpectedCallError('Not supported "getNamedItemNS" method');
|
|
19
14
|
}
|
|
20
15
|
item(index) {
|
|
21
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
56
|
+
throw new UnexpectedCallError('Not supported "setNamedItemNS" method');
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
|
-
|
|
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
|
|
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
|
-
|
|
34
|
-
return (_a = this[index]) !== null && _a !== void 0 ? _a : null;
|
|
29
|
+
return this[index] ?? null;
|
|
35
30
|
}
|
|
36
31
|
namedItem(name) {
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
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 =
|
|
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(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
4
|
-
import type {
|
|
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
|
/**
|
package/lib/ml-dom/node/node.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _MLNode_childNodes, _MLNode_ownerDocument, _MLNode_prevToken;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
134
|
-
|
|
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
|
|
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
|
-
|
|
155
|
-
|
|
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 (
|
|
157
|
+
if (isChildNode(node) && (node.parentNode === this || node.parentNode === null)) {
|
|
162
158
|
childNodes.push(node);
|
|
163
159
|
}
|
|
164
160
|
}
|
|
165
161
|
// Cache
|
|
166
|
-
|
|
167
|
-
return
|
|
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 =
|
|
169
|
+
const astChildren = this._astToken.childNodes ?? [];
|
|
174
170
|
const childNodes = astChildren
|
|
175
|
-
.map(node =>
|
|
176
|
-
.filter((node) =>
|
|
171
|
+
.map(node => nodeStore.getNode(node))
|
|
172
|
+
.filter((node) => isChildNode(node));
|
|
177
173
|
// Cache
|
|
178
|
-
|
|
179
|
-
return
|
|
174
|
+
__classPrivateFieldSet(this, _MLNode_childNodes, toNodeList(childNodes), "f");
|
|
175
|
+
return __classPrivateFieldGet(this, _MLNode_childNodes, "f");
|
|
180
176
|
}
|
|
181
177
|
// Cache
|
|
182
|
-
|
|
183
|
-
return
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
269
|
+
return __classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
|
|
276
270
|
}
|
|
277
271
|
get ownerMLDocument() {
|
|
278
|
-
return
|
|
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
|
|
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
|
-
|
|
376
|
-
|
|
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
|
-
|
|
395
|
-
return
|
|
387
|
+
__classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
|
|
388
|
+
return __classPrivateFieldGet(this, _MLNode_prevToken, "f");
|
|
396
389
|
}
|
|
397
|
-
|
|
398
|
-
return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|