@markuplint/ml-core 3.3.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/configs.js +1 -2
- package/lib/index.d.ts +1 -11
- package/lib/ml-core.d.ts +12 -23
- package/lib/ml-core.js +4 -4
- package/lib/ml-dom/helper/accname.js +15 -5
- package/lib/ml-dom/helper/create-node.d.ts +2 -5
- package/lib/ml-dom/helper/create-node.js +3 -1
- package/lib/ml-dom/helper/debug.js +6 -2
- package/lib/ml-dom/helper/getIndent.d.ts +7 -7
- package/lib/ml-dom/helper/getIndent.js +11 -3
- package/lib/ml-dom/helper/walkers.d.ts +5 -13
- package/lib/ml-dom/helper/walkers.js +3 -1
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +7 -20
- package/lib/ml-dom/manipulations/child-node-methods.js +24 -6
- package/lib/ml-dom/manipulations/get-children.d.ts +2 -4
- package/lib/ml-dom/manipulations/get-children.js +3 -1
- package/lib/ml-dom/node/attr.d.ts +91 -91
- package/lib/ml-dom/node/attr.js +5 -1
- package/lib/ml-dom/node/block.d.ts +32 -32
- package/lib/ml-dom/node/block.js +14 -4
- package/lib/ml-dom/node/character-data.d.ts +53 -60
- package/lib/ml-dom/node/character-data.js +9 -3
- package/lib/ml-dom/node/child-node.d.ts +3 -8
- package/lib/ml-dom/node/child-node.js +3 -1
- package/lib/ml-dom/node/comment.d.ts +13 -16
- package/lib/ml-dom/node/document-fragment.d.ts +20 -23
- package/lib/ml-dom/node/document-type.d.ts +32 -35
- package/lib/ml-dom/node/document-type.js +14 -4
- package/lib/ml-dom/node/document.d.ts +1590 -1603
- package/lib/ml-dom/node/document.js +41 -7
- package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
- package/lib/ml-dom/node/dom-token-list.js +8 -6
- package/lib/ml-dom/node/element.d.ts +1897 -1895
- package/lib/ml-dom/node/element.js +58 -14
- package/lib/ml-dom/node/named-node-map.d.ts +40 -45
- package/lib/ml-dom/node/named-node-map.js +11 -4
- package/lib/ml-dom/node/node-list.d.ts +4 -10
- package/lib/ml-dom/node/node-list.js +23 -4
- package/lib/ml-dom/node/node-store.d.ts +4 -4
- package/lib/ml-dom/node/node-store.js +8 -3
- package/lib/ml-dom/node/node.d.ts +473 -493
- package/lib/ml-dom/node/node.js +46 -16
- package/lib/ml-dom/node/parent-node.d.ts +58 -67
- package/lib/ml-dom/node/parent-node.js +9 -3
- package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
- package/lib/ml-dom/node/rule-mapper.js +9 -2
- package/lib/ml-dom/node/text.d.ts +47 -50
- package/lib/ml-dom/node/types.d.ts +14 -70
- package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -1
- package/lib/ml-dom/token/token.d.ts +44 -44
- package/lib/ml-rule/create-rule.d.ts +2 -2
- package/lib/ml-rule/create-test-rule.d.ts +4 -6
- package/lib/ml-rule/ml-rule-context.d.ts +50 -58
- package/lib/ml-rule/ml-rule-context.js +3 -1
- package/lib/ml-rule/ml-rule.d.ts +26 -28
- package/lib/ml-rule/ml-rule.js +30 -24
- package/lib/ml-rule/types.d.ts +17 -23
- package/lib/plugin/plugin.d.ts +1 -1
- package/lib/plugin/types.d.ts +7 -7
- package/lib/ruleset/index.d.ts +4 -4
- package/lib/ruleset/index.js +4 -4
- package/lib/test/index.d.ts +8 -20
- package/lib/test/index.js +1 -1
- package/lib/types.d.ts +9 -8
- package/lib/utils/get-location-from-chars.d.ts +4 -9
- package/package.json +14 -12
|
@@ -17,7 +17,11 @@ const parent_node_1 = require("./parent-node");
|
|
|
17
17
|
const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
|
|
18
18
|
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
19
19
|
class MLElement extends parent_node_1.MLParentNode {
|
|
20
|
-
constructor(
|
|
20
|
+
constructor(
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
22
|
+
astNode,
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
24
|
+
document) {
|
|
21
25
|
super(astNode, document);
|
|
22
26
|
_MLElement_attributes.set(this, void 0);
|
|
23
27
|
_MLElement_fixedNodeName.set(this, void 0);
|
|
@@ -1969,7 +1973,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1969
1973
|
/**
|
|
1970
1974
|
* @implements DOM API: `Element`
|
|
1971
1975
|
*/
|
|
1972
|
-
after(
|
|
1976
|
+
after(
|
|
1977
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1978
|
+
...nodes) {
|
|
1973
1979
|
(0, child_node_methods_1.after)(this, ...nodes);
|
|
1974
1980
|
}
|
|
1975
1981
|
/**
|
|
@@ -1979,7 +1985,11 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1979
1985
|
* @implements DOM API: `Element`
|
|
1980
1986
|
* @see https://www.w3.org/TR/web-animations-1/#dom-animatable-animate
|
|
1981
1987
|
*/
|
|
1982
|
-
animate(
|
|
1988
|
+
animate(
|
|
1989
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1990
|
+
keyframes,
|
|
1991
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1992
|
+
options) {
|
|
1983
1993
|
throw new unexpected_call_error_1.default('Not supported "animate" method');
|
|
1984
1994
|
}
|
|
1985
1995
|
/**
|
|
@@ -1999,13 +2009,17 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1999
2009
|
* @implements DOM API: `Element`
|
|
2000
2010
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-attachshadow%E2%91%A0
|
|
2001
2011
|
*/
|
|
2002
|
-
attachShadow(
|
|
2012
|
+
attachShadow(
|
|
2013
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2014
|
+
init) {
|
|
2003
2015
|
throw new unexpected_call_error_1.default('Not supported "attachShadow" method');
|
|
2004
2016
|
}
|
|
2005
2017
|
/**
|
|
2006
2018
|
* @implements DOM API: `Element`
|
|
2007
2019
|
*/
|
|
2008
|
-
before(
|
|
2020
|
+
before(
|
|
2021
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2022
|
+
...nodes) {
|
|
2009
2023
|
(0, child_node_methods_1.before)(this, ...nodes);
|
|
2010
2024
|
}
|
|
2011
2025
|
/**
|
|
@@ -2018,6 +2032,18 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2018
2032
|
blur() {
|
|
2019
2033
|
throw new unexpected_call_error_1.default('Not supported "blur" method');
|
|
2020
2034
|
}
|
|
2035
|
+
/**
|
|
2036
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2037
|
+
*
|
|
2038
|
+
* @deprecated
|
|
2039
|
+
* @unsupported
|
|
2040
|
+
* @implements DOM API: `Element`
|
|
2041
|
+
*/
|
|
2042
|
+
checkVisibility(
|
|
2043
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2044
|
+
options) {
|
|
2045
|
+
throw new unexpected_call_error_1.default('Not supported "checkVisibility" method');
|
|
2046
|
+
}
|
|
2021
2047
|
/**
|
|
2022
2048
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2023
2049
|
*
|
|
@@ -2052,7 +2078,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2052
2078
|
* @unsupported
|
|
2053
2079
|
* @implements DOM API: `Element`
|
|
2054
2080
|
*/
|
|
2055
|
-
focus(
|
|
2081
|
+
focus(
|
|
2082
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2083
|
+
options) {
|
|
2056
2084
|
throw new unexpected_call_error_1.default('Not supported "focus" method');
|
|
2057
2085
|
}
|
|
2058
2086
|
/**
|
|
@@ -2068,7 +2096,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2068
2096
|
* @implements DOM API: `Element`
|
|
2069
2097
|
* @see https://www.w3.org/TR/web-animations-1/#dom-animatable-getanimations
|
|
2070
2098
|
*/
|
|
2071
|
-
getAnimations(
|
|
2099
|
+
getAnimations(
|
|
2100
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2101
|
+
options) {
|
|
2072
2102
|
throw new unexpected_call_error_1.default('Not supported "getAnimations" method');
|
|
2073
2103
|
}
|
|
2074
2104
|
/**
|
|
@@ -2308,7 +2338,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2308
2338
|
* @implements DOM API: `Element`
|
|
2309
2339
|
* @see https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
|
|
2310
2340
|
*/
|
|
2311
|
-
insertAdjacentElement(where,
|
|
2341
|
+
insertAdjacentElement(where,
|
|
2342
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2343
|
+
element) {
|
|
2312
2344
|
// TODO:
|
|
2313
2345
|
throw new unexpected_call_error_1.default('Does not implement "insertAdjacentElement" method yet');
|
|
2314
2346
|
}
|
|
@@ -2511,13 +2543,17 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2511
2543
|
* @implements DOM API: `Element`
|
|
2512
2544
|
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
|
|
2513
2545
|
*/
|
|
2514
|
-
removeAttributeNode(
|
|
2546
|
+
removeAttributeNode(
|
|
2547
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2548
|
+
attr) {
|
|
2515
2549
|
throw new unexpected_call_error_1.default('Not supported "removeAttributeNode" method');
|
|
2516
2550
|
}
|
|
2517
2551
|
/**
|
|
2518
2552
|
* @implements DOM API: `Element`
|
|
2519
2553
|
*/
|
|
2520
|
-
replaceWith(
|
|
2554
|
+
replaceWith(
|
|
2555
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2556
|
+
...nodes) {
|
|
2521
2557
|
(0, child_node_methods_1.replaceWith)(this, ...nodes);
|
|
2522
2558
|
}
|
|
2523
2559
|
/**
|
|
@@ -2527,7 +2563,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2527
2563
|
* @implements DOM API: `Element`
|
|
2528
2564
|
* @see https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
|
|
2529
2565
|
*/
|
|
2530
|
-
requestFullscreen(
|
|
2566
|
+
requestFullscreen(
|
|
2567
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2568
|
+
options) {
|
|
2531
2569
|
throw new unexpected_call_error_1.default('Not supported "requestFullscreen" method');
|
|
2532
2570
|
}
|
|
2533
2571
|
/**
|
|
@@ -2567,7 +2605,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2567
2605
|
* @implements DOM API: `Element`
|
|
2568
2606
|
* @see https://www.w3.org/TR/cssom-view-1/#dom-element-scrollintoview
|
|
2569
2607
|
*/
|
|
2570
|
-
scrollIntoView(
|
|
2608
|
+
scrollIntoView(
|
|
2609
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2610
|
+
arg) {
|
|
2571
2611
|
throw new unexpected_call_error_1.default('Not supported "scrollIntoView" method');
|
|
2572
2612
|
}
|
|
2573
2613
|
/**
|
|
@@ -2607,7 +2647,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2607
2647
|
* @implements DOM API: `Element`
|
|
2608
2648
|
* @see https://dom.spec.whatwg.org/#dom-element-setattributenode
|
|
2609
2649
|
*/
|
|
2610
|
-
setAttributeNode(
|
|
2650
|
+
setAttributeNode(
|
|
2651
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2652
|
+
attr) {
|
|
2611
2653
|
throw new unexpected_call_error_1.default('Not supported "setAttributeNode" method');
|
|
2612
2654
|
}
|
|
2613
2655
|
/**
|
|
@@ -2617,7 +2659,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2617
2659
|
* @implements DOM API: `Element`
|
|
2618
2660
|
* @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
|
|
2619
2661
|
*/
|
|
2620
|
-
setAttributeNodeNS(
|
|
2662
|
+
setAttributeNodeNS(
|
|
2663
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
2664
|
+
attr) {
|
|
2621
2665
|
throw new unexpected_call_error_1.default('Not supported "setAttributeNodeNS" method');
|
|
2622
2666
|
}
|
|
2623
2667
|
/**
|
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
import type { MLAttr } from './attr';
|
|
2
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
-
export declare class MLNamedNodeMap<T extends RuleConfigValue, O =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* @implements DOM API: `NamedNodeMap`
|
|
42
|
-
*/
|
|
43
|
-
setNamedItemNS(attr: MLAttr<T, O>): MLAttr<T, O> | null;
|
|
2
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
+
export declare class MLNamedNodeMap<T extends RuleConfigValue, O extends PlainData = undefined> extends Array<MLAttr<T, O>> implements NamedNodeMap {
|
|
4
|
+
getNamedItem(qualifiedName: string): MLAttr<T, O> | null;
|
|
5
|
+
/**
|
|
6
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
7
|
+
*
|
|
8
|
+
* @unsupported
|
|
9
|
+
* @implements DOM API: `NamedNodeMap`
|
|
10
|
+
*/
|
|
11
|
+
getNamedItemNS(namespace: string | null, localName: string): Attr | null;
|
|
12
|
+
item(index: number): MLAttr<T, O> | null;
|
|
13
|
+
/**
|
|
14
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
15
|
+
*
|
|
16
|
+
* @unsupported
|
|
17
|
+
* @implements DOM API: `NamedNodeMap`
|
|
18
|
+
*/
|
|
19
|
+
removeNamedItem(qualifiedName: string): MLAttr<T, O>;
|
|
20
|
+
/**
|
|
21
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
22
|
+
*
|
|
23
|
+
* @unsupported
|
|
24
|
+
* @implements DOM API: `NamedNodeMap`
|
|
25
|
+
*/
|
|
26
|
+
removeNamedItemNS(namespace: string | null, localName: string): MLAttr<T, O>;
|
|
27
|
+
/**
|
|
28
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
29
|
+
*
|
|
30
|
+
* @unsupported
|
|
31
|
+
* @implements DOM API: `NamedNodeMap`
|
|
32
|
+
*/
|
|
33
|
+
setNamedItem(attr: MLAttr<T, O>): MLAttr<T, O> | null;
|
|
34
|
+
/**
|
|
35
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
36
|
+
*
|
|
37
|
+
* @unsupported
|
|
38
|
+
* @implements DOM API: `NamedNodeMap`
|
|
39
|
+
*/
|
|
40
|
+
setNamedItemNS(attr: MLAttr<T, O>): MLAttr<T, O> | null;
|
|
44
41
|
}
|
|
45
|
-
export declare function toNamedNodeMap<T extends RuleConfigValue, O =
|
|
46
|
-
nodes: ReadonlyArray<MLAttr<T, O>>,
|
|
47
|
-
): MLNamedNodeMap<T, O>;
|
|
42
|
+
export declare function toNamedNodeMap<T extends RuleConfigValue, O extends PlainData = undefined>(nodes: ReadonlyArray<MLAttr<T, O>>): MLNamedNodeMap<T, O>;
|
|
@@ -17,7 +17,8 @@ class MLNamedNodeMap extends Array {
|
|
|
17
17
|
throw new unexpected_call_error_1.default('Not supported "getNamedItemNS" method');
|
|
18
18
|
}
|
|
19
19
|
item(index) {
|
|
20
|
-
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = this[index]) !== null && _a !== void 0 ? _a : null;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -43,7 +44,9 @@ class MLNamedNodeMap extends Array {
|
|
|
43
44
|
* @unsupported
|
|
44
45
|
* @implements DOM API: `NamedNodeMap`
|
|
45
46
|
*/
|
|
46
|
-
setNamedItem(
|
|
47
|
+
setNamedItem(
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
49
|
+
attr) {
|
|
47
50
|
throw new unexpected_call_error_1.default('Not supported "setNamedItem" method');
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
@@ -52,12 +55,16 @@ class MLNamedNodeMap extends Array {
|
|
|
52
55
|
* @unsupported
|
|
53
56
|
* @implements DOM API: `NamedNodeMap`
|
|
54
57
|
*/
|
|
55
|
-
setNamedItemNS(
|
|
58
|
+
setNamedItemNS(
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
60
|
+
attr) {
|
|
56
61
|
throw new unexpected_call_error_1.default('Not supported "setNamedItemNS" method');
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
exports.MLNamedNodeMap = MLNamedNodeMap;
|
|
60
|
-
function toNamedNodeMap(
|
|
65
|
+
function toNamedNodeMap(
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
67
|
+
nodes) {
|
|
61
68
|
const namedNodeMap = new MLNamedNodeMap(...nodes);
|
|
62
69
|
return namedNodeMap;
|
|
63
70
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { MLChildNode } from './child-node';
|
|
2
2
|
import type { MLElement } from './element';
|
|
3
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
-
export declare function toNodeList<T extends RuleConfigValue, O, N extends MLChildNode<T, O>>(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function toHTMLCollection<T extends RuleConfigValue, O = null>(
|
|
8
|
-
nodes: ReadonlyArray<MLElement<T, O>>,
|
|
9
|
-
): HTMLCollectionOf<MLElement<T, O>>;
|
|
10
|
-
export declare function nodeListToHTMLCollection<T extends RuleConfigValue, O = null>(
|
|
11
|
-
nodeList: NodeListOf<MLChildNode<T, O>>,
|
|
12
|
-
): HTMLCollectionOf<MLElement<T, O>>;
|
|
3
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
+
export declare function toNodeList<T extends RuleConfigValue, O extends PlainData, N extends MLChildNode<T, O>>(nodes: ReadonlyArray<N>): NodeListOf<N>;
|
|
5
|
+
export declare function toHTMLCollection<T extends RuleConfigValue, O extends PlainData = undefined>(nodes: ReadonlyArray<MLElement<T, O>>): HTMLCollectionOf<MLElement<T, O>>;
|
|
6
|
+
export declare function nodeListToHTMLCollection<T extends RuleConfigValue, O extends PlainData = undefined>(nodeList: NodeListOf<MLChildNode<T, O>>): HTMLCollectionOf<MLElement<T, O>>;
|
|
@@ -6,7 +6,21 @@ class MLNodeList extends Array {
|
|
|
6
6
|
return super.forEach.bind(this)((v, k) => callbackfn(v, k, thisArg !== null && thisArg !== void 0 ? thisArg : this));
|
|
7
7
|
}
|
|
8
8
|
item(index) {
|
|
9
|
-
|
|
9
|
+
const node = this[index];
|
|
10
|
+
if (!node) {
|
|
11
|
+
/**
|
|
12
|
+
* ⚠ TYPE CONTRADICTION
|
|
13
|
+
*
|
|
14
|
+
* It throws an error because it should return null but the `item` method of `NodeListOf` doesn't return null in the type definition of TypeScript.
|
|
15
|
+
*
|
|
16
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-844377136
|
|
17
|
+
*
|
|
18
|
+
* > item
|
|
19
|
+
* > Returns the index-th item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
|
|
20
|
+
*/
|
|
21
|
+
throw new ReferenceError('Invalid index');
|
|
22
|
+
}
|
|
23
|
+
return node;
|
|
10
24
|
}
|
|
11
25
|
}
|
|
12
26
|
function toNodeList(nodes) {
|
|
@@ -16,18 +30,23 @@ function toNodeList(nodes) {
|
|
|
16
30
|
exports.toNodeList = toNodeList;
|
|
17
31
|
class MLHTMLCollection extends Array {
|
|
18
32
|
item(index) {
|
|
19
|
-
|
|
33
|
+
var _a;
|
|
34
|
+
return (_a = this[index]) !== null && _a !== void 0 ? _a : null;
|
|
20
35
|
}
|
|
21
36
|
namedItem(name) {
|
|
22
37
|
return this.find(el => el.getAttribute('name') === name) || null;
|
|
23
38
|
}
|
|
24
39
|
}
|
|
25
|
-
function toHTMLCollection(
|
|
40
|
+
function toHTMLCollection(
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
42
|
+
nodes) {
|
|
26
43
|
const collection = new MLHTMLCollection(...nodes);
|
|
27
44
|
return collection;
|
|
28
45
|
}
|
|
29
46
|
exports.toHTMLCollection = toHTMLCollection;
|
|
30
|
-
function nodeListToHTMLCollection(
|
|
47
|
+
function nodeListToHTMLCollection(
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
49
|
+
nodeList) {
|
|
31
50
|
const collection = new MLHTMLCollection();
|
|
32
51
|
nodeList.forEach(node => {
|
|
33
52
|
if (node.is(node.ELEMENT_NODE)) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { MLNode } from './node';
|
|
2
2
|
import type { MappedNode } from './types';
|
|
3
3
|
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
4
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
5
5
|
declare class NodeStore {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
#private;
|
|
7
|
+
getNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O extends PlainData = undefined>(astNode: N): MappedNode<N, T, O>;
|
|
8
|
+
setNode<A extends MLASTAbstractNode, T extends RuleConfigValue, O extends PlainData = undefined>(astNode: A, node: MLNode<T, O, A>): void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* `NodeStore` Singleton
|
|
@@ -16,7 +16,10 @@ class NodeStore {
|
|
|
16
16
|
const node = tslib_1.__classPrivateFieldGet(this, _NodeStore_store, "f").get(astNode.uuid);
|
|
17
17
|
if (!node) {
|
|
18
18
|
nodeStoreError('Ref ID: %s (%s: "%s")', astNode.uuid, astNode.nodeName, astNode.raw);
|
|
19
|
-
nodeStoreError('Map: %O', tslib_1.__classPrivateFieldGet(this, _NodeStore_store, "f"))
|
|
19
|
+
nodeStoreError('Map: %O', Array.from(tslib_1.__classPrivateFieldGet(this, _NodeStore_store, "f").entries()).map(([id, node]) => ({
|
|
20
|
+
id,
|
|
21
|
+
name: node.nodeName,
|
|
22
|
+
})));
|
|
20
23
|
throw new parser_utils_1.ParserError('Broke mapping nodes.', {
|
|
21
24
|
line: astNode.startLine,
|
|
22
25
|
col: astNode.startCol,
|
|
@@ -26,7 +29,9 @@ class NodeStore {
|
|
|
26
29
|
}
|
|
27
30
|
return node;
|
|
28
31
|
}
|
|
29
|
-
setNode(astNode,
|
|
32
|
+
setNode(astNode,
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
34
|
+
node) {
|
|
30
35
|
if (node.is(node.DOCUMENT_NODE)) {
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
@@ -34,7 +39,7 @@ class NodeStore {
|
|
|
34
39
|
nodeStoreError('UUID is invalid: %s (%s: "%s")', astNode.uuid, astNode.nodeName, astNode.raw);
|
|
35
40
|
nodeStoreError('Invalid node: %O', node);
|
|
36
41
|
}
|
|
37
|
-
nodeStoreLog('Mapped: %s (%s: "%s")', astNode.uuid, astNode.nodeName, astNode.raw);
|
|
42
|
+
nodeStoreLog('Mapped: %s (%s: "%s")', astNode.uuid, astNode.nodeName, astNode.raw.replace(/\n/g, '⏎').replace(/\t/g, '→'));
|
|
38
43
|
tslib_1.__classPrivateFieldGet(this, _NodeStore_store, "f").set(astNode.uuid, node);
|
|
39
44
|
}
|
|
40
45
|
}
|