@markuplint/ml-core 3.3.0 → 3.4.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/index.d.ts +11 -1
- package/lib/ml-core.d.ts +22 -11
- package/lib/ml-dom/helper/create-node.d.ts +4 -1
- package/lib/ml-dom/helper/getIndent.d.ts +7 -7
- package/lib/ml-dom/helper/walkers.d.ts +11 -3
- package/lib/ml-dom/helper/walkers.js +1 -0
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +18 -5
- package/lib/ml-dom/manipulations/get-children.d.ts +3 -1
- package/lib/ml-dom/node/attr.d.ts +89 -89
- package/lib/ml-dom/node/block.d.ts +30 -30
- package/lib/ml-dom/node/character-data.d.ts +59 -52
- package/lib/ml-dom/node/child-node.d.ts +6 -1
- package/lib/ml-dom/node/comment.d.ts +15 -12
- package/lib/ml-dom/node/document-fragment.d.ts +22 -19
- package/lib/ml-dom/node/document-type.d.ts +34 -31
- package/lib/ml-dom/node/document.d.ts +1600 -1586
- package/lib/ml-dom/node/document.js +12 -0
- package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
- package/lib/ml-dom/node/dom-token-list.js +5 -5
- package/lib/ml-dom/node/element.d.ts +1894 -1888
- package/lib/ml-dom/node/named-node-map.d.ts +44 -39
- package/lib/ml-dom/node/named-node-map.js +2 -1
- package/lib/ml-dom/node/node-list.d.ts +9 -3
- package/lib/ml-dom/node/node-list.js +17 -2
- package/lib/ml-dom/node/node-store.d.ts +3 -3
- package/lib/ml-dom/node/node.d.ts +492 -472
- package/lib/ml-dom/node/node.js +4 -2
- package/lib/ml-dom/node/parent-node.d.ts +66 -57
- package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
- package/lib/ml-dom/node/rule-mapper.js +3 -0
- package/lib/ml-dom/node/text.d.ts +49 -46
- package/lib/ml-dom/node/types.d.ts +67 -11
- package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -2
- package/lib/ml-dom/token/token.d.ts +44 -44
- package/lib/ml-rule/create-test-rule.d.ts +5 -3
- package/lib/ml-rule/ml-rule-context.d.ts +56 -48
- package/lib/ml-rule/ml-rule.d.ts +25 -23
- package/lib/ml-rule/types.d.ts +19 -13
- package/lib/plugin/types.d.ts +5 -5
- package/lib/ruleset/index.d.ts +4 -4
- package/lib/test/index.d.ts +19 -7
- package/lib/test/index.js +1 -1
- package/lib/types.d.ts +7 -7
- package/lib/utils/get-location-from-chars.d.ts +9 -4
- package/package.json +9 -7
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
import type { MLAttr } from './attr';
|
|
2
2
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
-
export declare class MLNamedNodeMap<T extends RuleConfigValue, O = null>
|
|
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
|
-
|
|
3
|
+
export declare class MLNamedNodeMap<T extends RuleConfigValue, O = null>
|
|
4
|
+
extends Array<MLAttr<T, O>>
|
|
5
|
+
implements NamedNodeMap
|
|
6
|
+
{
|
|
7
|
+
getNamedItem(qualifiedName: string): MLAttr<T, O> | null;
|
|
8
|
+
/**
|
|
9
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
10
|
+
*
|
|
11
|
+
* @unsupported
|
|
12
|
+
* @implements DOM API: `NamedNodeMap`
|
|
13
|
+
*/
|
|
14
|
+
getNamedItemNS(namespace: string | null, localName: string): Attr | null;
|
|
15
|
+
item(index: number): MLAttr<T, O> | null;
|
|
16
|
+
/**
|
|
17
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
18
|
+
*
|
|
19
|
+
* @unsupported
|
|
20
|
+
* @implements DOM API: `NamedNodeMap`
|
|
21
|
+
*/
|
|
22
|
+
removeNamedItem(qualifiedName: string): MLAttr<T, O>;
|
|
23
|
+
/**
|
|
24
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
25
|
+
*
|
|
26
|
+
* @unsupported
|
|
27
|
+
* @implements DOM API: `NamedNodeMap`
|
|
28
|
+
*/
|
|
29
|
+
removeNamedItemNS(namespace: string | null, localName: string): MLAttr<T, O>;
|
|
30
|
+
/**
|
|
31
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
32
|
+
*
|
|
33
|
+
* @unsupported
|
|
34
|
+
* @implements DOM API: `NamedNodeMap`
|
|
35
|
+
*/
|
|
36
|
+
setNamedItem(attr: MLAttr<T, O>): MLAttr<T, O> | null;
|
|
37
|
+
/**
|
|
38
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
39
|
+
*
|
|
40
|
+
* @unsupported
|
|
41
|
+
* @implements DOM API: `NamedNodeMap`
|
|
42
|
+
*/
|
|
43
|
+
setNamedItemNS(attr: MLAttr<T, O>): MLAttr<T, O> | null;
|
|
41
44
|
}
|
|
42
|
-
export declare function toNamedNodeMap<T extends RuleConfigValue, O = null>(
|
|
45
|
+
export declare function toNamedNodeMap<T extends RuleConfigValue, O = null>(
|
|
46
|
+
nodes: ReadonlyArray<MLAttr<T, O>>,
|
|
47
|
+
): 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.**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { MLChildNode } from './child-node';
|
|
2
2
|
import type { MLElement } from './element';
|
|
3
3
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
-
export declare function toNodeList<T extends RuleConfigValue, O, N extends MLChildNode<T, O>>(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare function toNodeList<T extends RuleConfigValue, O, N extends MLChildNode<T, O>>(
|
|
5
|
+
nodes: ReadonlyArray<N>,
|
|
6
|
+
): NodeListOf<N>;
|
|
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>>;
|
|
@@ -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,7 +30,8 @@ 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;
|
|
@@ -3,9 +3,9 @@ import type { MappedNode } from './types';
|
|
|
3
3
|
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
4
4
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
5
5
|
declare class NodeStore {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
#private;
|
|
7
|
+
getNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: N): MappedNode<N, T, O>;
|
|
8
|
+
setNode<A extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: A, node: MLNode<T, O, A>): void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* `NodeStore` Singleton
|