@markuplint/ml-core 3.0.0-dev.25 → 3.0.0-dev.300
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 -31
- 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 +13 -12
- package/lib/index.js +13 -29
- package/lib/ml-core.d.ts +7 -7
- package/lib/ml-core.js +60 -66
- package/lib/ml-dom/helper/accname.d.ts +1 -1
- package/lib/ml-dom/helper/accname.js +23 -19
- package/lib/ml-dom/helper/create-node.d.ts +4 -4
- package/lib/ml-dom/helper/create-node.js +13 -15
- package/lib/ml-dom/helper/debug.d.ts +1 -1
- package/lib/ml-dom/helper/debug.js +8 -8
- package/lib/ml-dom/helper/getIndent.d.ts +2 -2
- package/lib/ml-dom/helper/getIndent.js +30 -28
- package/lib/ml-dom/helper/walkers.d.ts +6 -6
- package/lib/ml-dom/helper/walkers.js +23 -22
- 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 +9 -9
- package/lib/ml-dom/manipulations/child-node-methods.js +31 -25
- package/lib/ml-dom/manipulations/get-children.d.ts +4 -4
- package/lib/ml-dom/manipulations/get-children.js +5 -7
- package/lib/ml-dom/node/attr.d.ts +7 -7
- package/lib/ml-dom/node/attr.js +33 -34
- package/lib/ml-dom/node/block.d.ts +6 -6
- package/lib/ml-dom/node/block.js +21 -15
- package/lib/ml-dom/node/character-data.d.ts +4 -4
- package/lib/ml-dom/node/character-data.js +20 -19
- package/lib/ml-dom/node/child-node.d.ts +9 -9
- package/lib/ml-dom/node/child-node.js +3 -5
- package/lib/ml-dom/node/comment.d.ts +4 -4
- package/lib/ml-dom/node/comment.js +2 -6
- package/lib/ml-dom/node/document-fragment.d.ts +4 -4
- package/lib/ml-dom/node/document-fragment.js +4 -9
- package/lib/ml-dom/node/document-type.d.ts +6 -6
- package/lib/ml-dom/node/document-type.js +21 -15
- package/lib/ml-dom/node/document.d.ts +32 -29
- package/lib/ml-dom/node/document.js +329 -246
- package/lib/ml-dom/node/dom-token-list.d.ts +3 -3
- package/lib/ml-dom/node/dom-token-list.js +29 -33
- package/lib/ml-dom/node/element.d.ts +65 -16
- package/lib/ml-dom/node/element.js +396 -306
- package/lib/ml-dom/node/named-node-map.d.ts +4 -4
- package/lib/ml-dom/node/named-node-map.js +18 -18
- package/lib/ml-dom/node/node-list.d.ts +6 -6
- package/lib/ml-dom/node/node-list.js +25 -13
- package/lib/ml-dom/node/node-store.d.ts +5 -5
- package/lib/ml-dom/node/node-store.js +25 -10
- package/lib/ml-dom/node/node.d.ts +12 -12
- package/lib/ml-dom/node/node.js +101 -76
- package/lib/ml-dom/node/parent-node.d.ts +6 -6
- package/lib/ml-dom/node/parent-node.js +31 -29
- package/lib/ml-dom/node/rule-mapper.d.ts +5 -5
- package/lib/ml-dom/node/rule-mapper.js +20 -17
- package/lib/ml-dom/node/text.d.ts +4 -4
- package/lib/ml-dom/node/text.js +6 -11
- package/lib/ml-dom/node/types.d.ts +30 -16
- 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 +3 -3
- package/lib/ml-rule/create-rule.js +1 -5
- package/lib/ml-rule/create-test-rule.d.ts +5 -5
- 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 +4 -4
- package/lib/ml-rule/ml-rule-context.js +11 -13
- package/lib/ml-rule/ml-rule.d.ts +9 -9
- package/lib/ml-rule/ml-rule.js +48 -45
- package/lib/ml-rule/types.d.ts +12 -12
- 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 +2 -2
- package/lib/plugin/plugin.js +1 -5
- package/lib/plugin/types.d.ts +6 -6
- package/lib/plugin/types.js +1 -2
- package/lib/ruleset/index.d.ts +3 -3
- package/lib/ruleset/index.js +4 -8
- package/lib/test/index.d.ts +9 -9
- package/lib/test/index.js +14 -24
- package/lib/types.d.ts +11 -10
- package/lib/types.js +1 -2
- package/lib/utils/get-location-from-chars.d.ts +1 -1
- 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 +25 -16
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _MLDOMIndentation_fixed, _MLDOMIndentation_node, _MLDOMIndentation_parent;
|
|
3
|
-
|
|
4
|
-
exports.getIndent = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
6
3
|
/**
|
|
7
4
|
*
|
|
8
5
|
* @deprecated
|
|
9
6
|
* @param node
|
|
10
7
|
*/
|
|
11
|
-
function getIndent(
|
|
8
|
+
export function getIndent(
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
|
+
node) {
|
|
12
11
|
const prevToken = node.prevToken;
|
|
13
12
|
if (!prevToken) {
|
|
14
13
|
return null;
|
|
@@ -49,52 +48,55 @@ function getIndent(node) {
|
|
|
49
48
|
}
|
|
50
49
|
return null;
|
|
51
50
|
}
|
|
52
|
-
exports.getIndent = getIndent;
|
|
53
51
|
class MLDOMIndentation {
|
|
54
|
-
constructor(
|
|
52
|
+
constructor(
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
54
|
+
originTextNode, raw, line,
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
56
|
+
parentNode) {
|
|
55
57
|
_MLDOMIndentation_fixed.set(this, void 0);
|
|
56
58
|
_MLDOMIndentation_node.set(this, void 0);
|
|
57
59
|
_MLDOMIndentation_parent.set(this, void 0);
|
|
58
60
|
this.line = line;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
__classPrivateFieldSet(this, _MLDOMIndentation_node, originTextNode, "f");
|
|
62
|
+
__classPrivateFieldSet(this, _MLDOMIndentation_parent, parentNode, "f");
|
|
63
|
+
__classPrivateFieldSet(this, _MLDOMIndentation_fixed, raw, "f");
|
|
62
64
|
}
|
|
63
65
|
get raw() {
|
|
64
|
-
if (!
|
|
66
|
+
if (!__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== __classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
|
|
65
67
|
return '';
|
|
66
68
|
}
|
|
67
|
-
return
|
|
69
|
+
return __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
|
|
68
70
|
}
|
|
69
71
|
get type() {
|
|
70
|
-
if (!
|
|
72
|
+
if (!__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== __classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
|
|
71
73
|
return 'none';
|
|
72
74
|
}
|
|
73
|
-
const raw =
|
|
75
|
+
const raw = __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
|
|
74
76
|
return raw === '' ? 'none' : /^\t+$/.test(raw) ? 'tab' : /^[^\t]+$/.test(raw) ? 'space' : 'mixed';
|
|
75
77
|
}
|
|
76
78
|
get width() {
|
|
77
|
-
if (!
|
|
79
|
+
if (!__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").is(__classPrivateFieldGet(this, _MLDOMIndentation_parent, "f").TEXT_NODE) && this.line !== __classPrivateFieldGet(this, _MLDOMIndentation_node, "f").endLine) {
|
|
78
80
|
return 0;
|
|
79
81
|
}
|
|
80
|
-
return
|
|
82
|
+
return __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f").length;
|
|
81
83
|
}
|
|
82
84
|
fix(raw) {
|
|
83
|
-
const current =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
lines[index] = lines[index].replace(current, tslib_1.__classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f"));
|
|
92
|
-
}
|
|
93
|
-
node.fix(lines.join('\n'));
|
|
85
|
+
const current = __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f");
|
|
86
|
+
__classPrivateFieldSet(this, _MLDOMIndentation_fixed, raw, "f");
|
|
87
|
+
const node = __classPrivateFieldGet(this, _MLDOMIndentation_node, "f");
|
|
88
|
+
const line = node.startLine;
|
|
89
|
+
const lines = node.raw.split(/\r?\n/);
|
|
90
|
+
const index = this.line - line;
|
|
91
|
+
if (lines[index] != null) {
|
|
92
|
+
lines[index] = lines[index].replace(current, __classPrivateFieldGet(this, _MLDOMIndentation_fixed, "f"));
|
|
94
93
|
}
|
|
94
|
+
node.fix(lines.join('\n'));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
_MLDOMIndentation_fixed = new WeakMap(), _MLDOMIndentation_node = new WeakMap(), _MLDOMIndentation_parent = new WeakMap();
|
|
98
|
-
function isFirstToken(
|
|
98
|
+
function isFirstToken(
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
100
|
+
node) {
|
|
99
101
|
return !node.prevToken;
|
|
100
102
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MLNode } from '../node/node';
|
|
2
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
-
export type Walker<T extends RuleConfigValue, O =
|
|
4
|
-
export type SyncWalker<T extends RuleConfigValue, O =
|
|
5
|
-
export declare function syncWalk<T extends RuleConfigValue, O =
|
|
6
|
-
export declare function sequentialWalker<T extends RuleConfigValue, O =
|
|
1
|
+
import type { MLNode } from '../node/node.js';
|
|
2
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
+
export type Walker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>> = (node: N) => void | Promise<void> | Promise<void>[];
|
|
4
|
+
export type SyncWalker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>> = (node: N) => void;
|
|
5
|
+
export declare function syncWalk<T extends RuleConfigValue, O extends PlainData = undefined>(nodeList: ReadonlyArray<MLNode<T, O>>, walker: SyncWalker<T, O>): void;
|
|
6
|
+
export declare function sequentialWalker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>>(list: ReadonlyArray<N>, walker: Walker<T, O, N>): Promise<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function syncWalk(nodeList, walker) {
|
|
1
|
+
export function syncWalk(
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
3
|
+
nodeList, walker) {
|
|
5
4
|
for (const node of nodeList) {
|
|
6
5
|
if (node.is(node.ELEMENT_NODE) || node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK)) {
|
|
7
6
|
syncWalk(Array.from(node.childNodes), walker);
|
|
@@ -9,8 +8,7 @@ function syncWalk(nodeList, walker) {
|
|
|
9
8
|
walker(node);
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
function sequentialWalker(list, walker) {
|
|
11
|
+
export function sequentialWalker(list, walker) {
|
|
14
12
|
if (list.length === 0) {
|
|
15
13
|
return Promise.resolve();
|
|
16
14
|
}
|
|
@@ -25,24 +23,27 @@ function sequentialWalker(list, walker) {
|
|
|
25
23
|
_reject = reject;
|
|
26
24
|
});
|
|
27
25
|
const loop = (index = 0) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
result
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
// eslint-disable-next-line no-constant-condition
|
|
27
|
+
while (true) {
|
|
28
|
+
if (index >= list.length) {
|
|
29
|
+
_resolve();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const node = list[index];
|
|
33
|
+
if (node == null) {
|
|
34
|
+
_resolve();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const result = walker(node);
|
|
38
|
+
if (result instanceof Promise) {
|
|
39
|
+
result.then(() => loop(index + 1)).catch(_reject);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
index = index + 1;
|
|
44
|
+
}
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
loop();
|
|
46
48
|
return promise;
|
|
47
49
|
}
|
|
48
|
-
exports.sequentialWalker = sequentialWalker;
|
package/lib/ml-dom/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type { MLAttr as Attr } from './node/attr';
|
|
2
|
-
export type { MLBlock as Block } from './node/block';
|
|
3
|
-
export type { MLComment as Comment } from './node/comment';
|
|
4
|
-
export type { MLDocumentFragment as DocumentFragment } from './node/document-fragment';
|
|
5
|
-
export type { MLDocumentType as DocumentType } from './node/document-type';
|
|
6
|
-
export type { MLElement as Element } from './node/element';
|
|
7
|
-
export type { MLText as Text } from './node/text';
|
|
8
|
-
export type { MLChildNode as ChildNode } from './node/child-node';
|
|
9
|
-
export { MLDocument as Document } from './node/document';
|
|
1
|
+
export type { MLAttr as Attr } from './node/attr.js';
|
|
2
|
+
export type { MLBlock as Block } from './node/block.js';
|
|
3
|
+
export type { MLComment as Comment } from './node/comment.js';
|
|
4
|
+
export type { MLDocumentFragment as DocumentFragment } from './node/document-fragment.js';
|
|
5
|
+
export type { MLDocumentType as DocumentType } from './node/document-type.js';
|
|
6
|
+
export type { MLElement as Element } from './node/element.js';
|
|
7
|
+
export type { MLText as Text } from './node/text.js';
|
|
8
|
+
export type { MLChildNode as ChildNode } from './node/child-node.js';
|
|
9
|
+
export { MLDocument as Document } from './node/document.js';
|
package/lib/ml-dom/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Document = void 0;
|
|
4
|
-
var document_1 = require("./node/document");
|
|
5
|
-
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.MLDocument; } });
|
|
1
|
+
export { MLDocument as Document } from './node/document.js';
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import type { MLElement } from '../node/element';
|
|
2
|
-
import type { MLNode } from '../node/node';
|
|
3
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
1
|
+
import type { MLElement } from '../node/element.js';
|
|
2
|
+
import type { MLNode } from '../node/node.js';
|
|
3
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
|
|
7
7
|
*/
|
|
8
|
-
export declare function before<T extends RuleConfigValue, O =
|
|
8
|
+
export declare function before<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
11
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
|
|
12
12
|
*/
|
|
13
|
-
export declare function after<T extends RuleConfigValue, O =
|
|
13
|
+
export declare function after<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
|
|
17
17
|
*/
|
|
18
|
-
export declare function replaceWith<T extends RuleConfigValue, O =
|
|
18
|
+
export declare function replaceWith<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
21
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
|
|
22
22
|
*/
|
|
23
|
-
export declare function remove<T extends RuleConfigValue, O =
|
|
23
|
+
export declare function remove<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): void;
|
|
24
24
|
/**
|
|
25
25
|
*
|
|
26
26
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
|
|
27
27
|
*/
|
|
28
|
-
export declare function previousElementSibling<T extends RuleConfigValue, O =
|
|
28
|
+
export declare function previousElementSibling<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): MLElement<T, O> | null;
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
31
31
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
|
|
32
32
|
*/
|
|
33
|
-
export declare function nextElementSibling<T extends RuleConfigValue, O =
|
|
33
|
+
export declare function nextElementSibling<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): MLElement<T, O> | null;
|
|
@@ -1,50 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nextElementSibling = exports.previousElementSibling = exports.remove = exports.replaceWith = exports.after = exports.before = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const unexpected_call_error_1 = tslib_1.__importDefault(require("../node/unexpected-call-error"));
|
|
1
|
+
import UnexpectedCallError from '../node/unexpected-call-error.js';
|
|
6
2
|
/**
|
|
7
3
|
*
|
|
8
4
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
|
|
9
5
|
*/
|
|
10
|
-
function before(
|
|
11
|
-
|
|
6
|
+
export function before(
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
|
+
node,
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
|
+
...additionalNodes) {
|
|
11
|
+
throw new UnexpectedCallError('Not supported "before" method');
|
|
12
12
|
}
|
|
13
|
-
exports.before = before;
|
|
14
13
|
/**
|
|
15
14
|
*
|
|
16
15
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
|
|
17
16
|
*/
|
|
18
|
-
function after(
|
|
19
|
-
|
|
17
|
+
export function after(
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
19
|
+
node,
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
21
|
+
...additionalNodes) {
|
|
22
|
+
throw new UnexpectedCallError('Not supported "after" method');
|
|
20
23
|
}
|
|
21
|
-
exports.after = after;
|
|
22
24
|
/**
|
|
23
25
|
*
|
|
24
26
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
|
|
25
27
|
*/
|
|
26
|
-
function replaceWith(
|
|
27
|
-
|
|
28
|
+
export function replaceWith(
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
30
|
+
node,
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
32
|
+
...additionalNodes) {
|
|
33
|
+
throw new UnexpectedCallError('Not supported "replaceWith" method');
|
|
28
34
|
}
|
|
29
|
-
exports.replaceWith = replaceWith;
|
|
30
35
|
/**
|
|
31
36
|
*
|
|
32
37
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
|
|
33
38
|
*/
|
|
34
|
-
function remove(
|
|
35
|
-
|
|
39
|
+
export function remove(
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
41
|
+
node) {
|
|
42
|
+
throw new UnexpectedCallError('Not supported "remove" method');
|
|
36
43
|
}
|
|
37
|
-
exports.remove = remove;
|
|
38
44
|
/**
|
|
39
45
|
*
|
|
40
46
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
|
|
41
47
|
*/
|
|
42
|
-
function previousElementSibling(
|
|
43
|
-
|
|
48
|
+
export function previousElementSibling(
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
50
|
+
node) {
|
|
44
51
|
let prevNode = node.prevNode;
|
|
45
52
|
while (prevNode) {
|
|
46
53
|
if (((node.parentNode === null && prevNode.parentNode === null) ||
|
|
47
|
-
|
|
54
|
+
node.parentNode?.uuid === prevNode.parentNode?.uuid) &&
|
|
48
55
|
prevNode.is(prevNode.ELEMENT_NODE)) {
|
|
49
56
|
return prevNode;
|
|
50
57
|
}
|
|
@@ -52,17 +59,17 @@ function previousElementSibling(node) {
|
|
|
52
59
|
}
|
|
53
60
|
return null;
|
|
54
61
|
}
|
|
55
|
-
exports.previousElementSibling = previousElementSibling;
|
|
56
62
|
/**
|
|
57
63
|
*
|
|
58
64
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
|
|
59
65
|
*/
|
|
60
|
-
function nextElementSibling(
|
|
61
|
-
|
|
66
|
+
export function nextElementSibling(
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
68
|
+
node) {
|
|
62
69
|
let nextNode = node.nextNode;
|
|
63
70
|
while (nextNode) {
|
|
64
71
|
if (((node.parentNode === null && nextNode.parentNode === null) ||
|
|
65
|
-
|
|
72
|
+
node.parentNode?.uuid === nextNode.parentNode?.uuid) &&
|
|
66
73
|
nextNode.is(nextNode.ELEMENT_NODE)) {
|
|
67
74
|
return nextNode;
|
|
68
75
|
}
|
|
@@ -70,4 +77,3 @@ function nextElementSibling(node) {
|
|
|
70
77
|
}
|
|
71
78
|
return null;
|
|
72
79
|
}
|
|
73
|
-
exports.nextElementSibling = nextElementSibling;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MLElement } from '../node/element';
|
|
2
|
-
import type { MLNode } from '../node/node';
|
|
3
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
-
export declare function getChildren<T extends RuleConfigValue, O =
|
|
1
|
+
import type { MLElement } from '../node/element.js';
|
|
2
|
+
import type { MLNode } from '../node/node.js';
|
|
3
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
+
export declare function getChildren<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): HTMLCollectionOf<MLElement<T, O>>;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return (0, node_list_1.toHTMLCollection)(Array.from(node.childNodes).filter((child) => {
|
|
1
|
+
import { toHTMLCollection } from '../node/node-list.js';
|
|
2
|
+
export function getChildren(
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
|
+
node) {
|
|
5
|
+
return toHTMLCollection(Array.from(node.childNodes).filter((child) => {
|
|
7
6
|
return child.nodeType === child.ELEMENT_NODE;
|
|
8
7
|
}));
|
|
9
8
|
}
|
|
10
|
-
exports.getChildren = getChildren;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { MLElement } from './element';
|
|
2
|
-
import type { AttributeNodeType } from './types';
|
|
1
|
+
import type { MLElement } from './element.js';
|
|
2
|
+
import type { AttributeNodeType } from './types.js';
|
|
3
3
|
import type { MLASTAttr } from '@markuplint/ml-ast';
|
|
4
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
5
|
-
import { MLToken } from '../token/token';
|
|
6
|
-
import { MLDomTokenList } from './dom-token-list';
|
|
7
|
-
import { MLNode } from './node';
|
|
8
|
-
export declare class MLAttr<T extends RuleConfigValue, O =
|
|
4
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
5
|
+
import { MLToken } from '../token/token.js';
|
|
6
|
+
import { MLDomTokenList } from './dom-token-list.js';
|
|
7
|
+
import { MLNode } from './node.js';
|
|
8
|
+
export declare class MLAttr<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTAttr> implements Attr {
|
|
9
9
|
#private;
|
|
10
10
|
readonly candidate?: string;
|
|
11
11
|
readonly endQuote: MLToken | null;
|
package/lib/ml-dom/node/attr.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _MLAttr_localName, _MLAttr_namespaceURI, _MLAttr_potentialName, _MLAttr_potentialValue;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
import { resolveNamespace } from '@markuplint/ml-spec';
|
|
4
|
+
import { MLToken } from '../token/token.js';
|
|
5
|
+
import { MLDomTokenList } from './dom-token-list.js';
|
|
6
|
+
import { MLNode } from './node.js';
|
|
7
|
+
import UnexpectedCallError from './unexpected-call-error.js';
|
|
8
|
+
export class MLAttr extends MLNode {
|
|
9
|
+
constructor(
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
11
|
+
astToken,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
13
|
+
ownElement) {
|
|
14
14
|
super(astToken, ownElement.ownerMLDocument);
|
|
15
15
|
this.endQuote = null;
|
|
16
16
|
this.equal = null;
|
|
@@ -32,29 +32,29 @@ class MLAttr extends node_1.MLNode {
|
|
|
32
32
|
*/
|
|
33
33
|
this.valueType = 'string';
|
|
34
34
|
if (this._astToken.type === 'html-attr') {
|
|
35
|
-
this.spacesBeforeName = new
|
|
36
|
-
this.nameNode = new
|
|
37
|
-
this.spacesBeforeEqual = new
|
|
38
|
-
this.equal = new
|
|
39
|
-
this.spacesAfterEqual = new
|
|
40
|
-
this.startQuote = new
|
|
41
|
-
this.valueNode = new
|
|
42
|
-
this.endQuote = new
|
|
35
|
+
this.spacesBeforeName = new MLToken(this._astToken.spacesBeforeName);
|
|
36
|
+
this.nameNode = new MLToken(this._astToken.name);
|
|
37
|
+
this.spacesBeforeEqual = new MLToken(this._astToken.spacesBeforeEqual);
|
|
38
|
+
this.equal = new MLToken(this._astToken.equal);
|
|
39
|
+
this.spacesAfterEqual = new MLToken(this._astToken.spacesAfterEqual);
|
|
40
|
+
this.startQuote = new MLToken(this._astToken.startQuote);
|
|
41
|
+
this.valueNode = new MLToken(this._astToken.value);
|
|
42
|
+
this.endQuote = new MLToken(this._astToken.endQuote);
|
|
43
43
|
this.isDynamicValue = this._astToken.isDynamicValue;
|
|
44
44
|
this.isDirective = this._astToken.isDirective;
|
|
45
45
|
this.candidate = this._astToken.candidate;
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName ?? this.nameNode?.raw ?? '', "f");
|
|
47
|
+
__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.value.raw ?? '', "f");
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
this.valueType = this._astToken.valueType;
|
|
51
51
|
this.isDuplicatable = this._astToken.isDuplicatable;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName, "f");
|
|
53
|
+
__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.potentialValue, "f");
|
|
54
54
|
}
|
|
55
|
-
const ns =
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const ns = resolveNamespace(__classPrivateFieldGet(this, _MLAttr_potentialName, "f"), ownElement.namespaceURI);
|
|
56
|
+
__classPrivateFieldSet(this, _MLAttr_localName, ns.localName, "f");
|
|
57
|
+
__classPrivateFieldSet(this, _MLAttr_namespaceURI, ns.namespaceURI, "f");
|
|
58
58
|
this.ownerElement = ownElement;
|
|
59
59
|
this.isDuplicatable = this._astToken.isDuplicatable;
|
|
60
60
|
}
|
|
@@ -66,7 +66,7 @@ class MLAttr extends node_1.MLNode {
|
|
|
66
66
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
|
|
67
67
|
*/
|
|
68
68
|
get localName() {
|
|
69
|
-
return
|
|
69
|
+
return __classPrivateFieldGet(this, _MLAttr_localName, "f");
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
*
|
|
@@ -74,7 +74,7 @@ class MLAttr extends node_1.MLNode {
|
|
|
74
74
|
* @see https://dom.spec.whatwg.org/#dom-attr-name
|
|
75
75
|
*/
|
|
76
76
|
get name() {
|
|
77
|
-
return
|
|
77
|
+
return __classPrivateFieldGet(this, _MLAttr_potentialName, "f");
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -84,7 +84,7 @@ class MLAttr extends node_1.MLNode {
|
|
|
84
84
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
|
|
85
85
|
*/
|
|
86
86
|
get namespaceURI() {
|
|
87
|
-
return
|
|
87
|
+
return __classPrivateFieldGet(this, _MLAttr_namespaceURI, "f");
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Returns a string appropriate for the type of node as `Attr`
|
|
@@ -111,7 +111,7 @@ class MLAttr extends node_1.MLNode {
|
|
|
111
111
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
|
|
112
112
|
*/
|
|
113
113
|
get prefix() {
|
|
114
|
-
throw new
|
|
114
|
+
throw new UnexpectedCallError('Not supported "prefix" property');
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
@@ -130,14 +130,14 @@ class MLAttr extends node_1.MLNode {
|
|
|
130
130
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
131
131
|
*/
|
|
132
132
|
get tokenList() {
|
|
133
|
-
return this.isDynamicValue ? null : new
|
|
133
|
+
return this.isDynamicValue ? null : new MLDomTokenList(this.value, [this]);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* @implements DOM API: `Attr`
|
|
137
137
|
* @see https://dom.spec.whatwg.org/#dom-attr-value
|
|
138
138
|
*/
|
|
139
139
|
get value() {
|
|
140
|
-
return
|
|
140
|
+
return __classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
@@ -153,5 +153,4 @@ class MLAttr extends node_1.MLNode {
|
|
|
153
153
|
return this.raw;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
exports.MLAttr = MLAttr;
|
|
157
156
|
_MLAttr_localName = new WeakMap(), _MLAttr_namespaceURI = new WeakMap(), _MLAttr_potentialName = new WeakMap(), _MLAttr_potentialValue = new WeakMap();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { MLDocument } from './document';
|
|
2
|
-
import type { MLElement } from './element';
|
|
3
|
-
import type { MarkuplintPreprocessorBlockType } from './types';
|
|
1
|
+
import type { MLDocument } from './document.js';
|
|
2
|
+
import type { MLElement } from './element.js';
|
|
3
|
+
import type { MarkuplintPreprocessorBlockType } from './types.js';
|
|
4
4
|
import type { MLASTPreprocessorSpecificBlock } from '@markuplint/ml-ast';
|
|
5
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
6
|
-
import { MLNode } from './node';
|
|
7
|
-
export declare class MLBlock<T extends RuleConfigValue, O =
|
|
5
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
6
|
+
import { MLNode } from './node.js';
|
|
7
|
+
export declare class MLBlock<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
|
|
8
8
|
readonly isTransparent: boolean;
|
|
9
9
|
constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
|
|
10
10
|
/**
|
package/lib/ml-dom/node/block.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { after, before, remove, replaceWith } from '../manipulations/child-node-methods.js';
|
|
2
|
+
import { MLNode } from './node.js';
|
|
3
|
+
export class MLBlock extends MLNode {
|
|
4
|
+
constructor(
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
6
|
+
astNode,
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
|
+
document) {
|
|
8
9
|
super(astNode, document);
|
|
9
10
|
// TODO:
|
|
10
11
|
this.isTransparent = true;
|
|
@@ -28,26 +29,31 @@ class MLBlock extends node_1.MLNode {
|
|
|
28
29
|
/**
|
|
29
30
|
* @implements DOM API: `ChildNode`
|
|
30
31
|
*/
|
|
31
|
-
after(
|
|
32
|
-
|
|
32
|
+
after(
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
34
|
+
...nodes) {
|
|
35
|
+
after(this, ...nodes);
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
38
|
* @implements DOM API: `ChildNode`
|
|
36
39
|
*/
|
|
37
|
-
before(
|
|
38
|
-
|
|
40
|
+
before(
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
42
|
+
...nodes) {
|
|
43
|
+
before(this, ...nodes);
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
41
46
|
* @implements DOM API: `ChildNode`
|
|
42
47
|
*/
|
|
43
48
|
remove() {
|
|
44
|
-
|
|
49
|
+
remove(this);
|
|
45
50
|
}
|
|
46
51
|
/**
|
|
47
52
|
* @implements DOM API: `ChildNode`
|
|
48
53
|
*/
|
|
49
|
-
replaceWith(
|
|
50
|
-
|
|
54
|
+
replaceWith(
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
56
|
+
...nodes) {
|
|
57
|
+
replaceWith(this, ...nodes);
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
|
-
exports.MLBlock = MLBlock;
|