@markuplint/ml-core 2.2.2 → 2.3.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/ml-core.d.ts +1 -1
- package/lib/ml-dom/helper/accname.js +1 -0
- package/lib/ml-dom/helper/selector.d.ts +1 -1
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +33 -0
- package/lib/ml-dom/manipulations/child-node-methods.js +73 -0
- package/lib/ml-dom/manipulations/get-children.d.ts +4 -0
- package/lib/ml-dom/manipulations/get-children.js +10 -0
- package/lib/ml-dom/node/attr.d.ts +93 -0
- package/lib/ml-dom/node/attr.js +144 -0
- package/lib/ml-dom/node/block.d.ts +38 -0
- package/lib/ml-dom/node/block.js +53 -0
- package/lib/ml-dom/node/character-data.d.ts +57 -0
- package/lib/ml-dom/node/character-data.js +87 -0
- package/lib/ml-dom/node/child-node.d.ts +9 -0
- package/lib/ml-dom/node/child-node.js +10 -0
- package/lib/ml-dom/node/comment.d.ts +17 -0
- package/lib/ml-dom/node/comment.js +24 -0
- package/lib/ml-dom/node/document-fragment.d.ts +24 -0
- package/lib/ml-dom/node/document-fragment.js +33 -0
- package/lib/ml-dom/node/document-type.d.ts +38 -0
- package/lib/ml-dom/node/document-type.js +52 -0
- package/lib/ml-dom/node/document.d.ts +1554 -0
- package/lib/ml-dom/node/document.js +2117 -0
- package/lib/ml-dom/node/dom-token-list.d.ts +15 -0
- package/lib/ml-dom/node/dom-token-list.js +61 -0
- package/lib/ml-dom/node/element.d.ts +1832 -0
- package/lib/ml-dom/node/element.js +2483 -0
- package/lib/ml-dom/node/named-node-map.d.ts +42 -0
- package/lib/ml-dom/node/named-node-map.js +64 -0
- package/lib/ml-dom/node/node-list.d.ts +6 -0
- package/lib/ml-dom/node/node-list.js +39 -0
- package/lib/ml-dom/node/node-store.d.ts +14 -0
- package/lib/ml-dom/node/node-store.js +32 -0
- package/lib/ml-dom/node/node.d.ts +475 -0
- package/lib/ml-dom/node/node.js +672 -0
- package/lib/ml-dom/node/parent-node.d.ts +66 -0
- package/lib/ml-dom/node/parent-node.js +131 -0
- package/lib/ml-dom/node/rule-mapper.d.ts +17 -0
- package/lib/ml-dom/node/rule-mapper.js +49 -0
- package/lib/ml-dom/node/text.d.ts +51 -0
- package/lib/ml-dom/node/text.js +76 -0
- package/lib/ml-dom/node/types.d.ts +25 -0
- package/lib/ml-dom/node/types.js +2 -0
- package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -0
- package/lib/ml-dom/node/unexpected-call-error.js +5 -0
- package/lib/ml-dom/token/token.d.ts +47 -0
- package/lib/ml-dom/token/token.js +89 -0
- package/lib/ml-dom/tokens/abstract-element.d.ts +1 -2
- package/lib/ml-dom/tokens/abstract-element.js +0 -4
- package/lib/ml-dom/tokens/node.d.ts +1 -0
- package/lib/ml-dom/tokens/node.js +8 -0
- package/lib/selector/is-pure-html-element.d.ts +1 -0
- package/lib/selector/is-pure-html-element.js +7 -0
- package/lib/selector/match-selector.d.ts +14 -0
- package/lib/selector/match-selector.js +230 -0
- package/lib/selector/selector.d.ts +9 -0
- package/lib/selector/selector.js +561 -0
- package/lib/utils/get-location-from-chars.d.ts +9 -4
- package/package.json +6 -6
- package/tsconfig.tsbuildinfo +1 -1
package/lib/ml-core.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare type MLCoreParams = {
|
|
|
10
10
|
export declare class MLCore {
|
|
11
11
|
#private;
|
|
12
12
|
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, filename, debug }: MLCoreParams);
|
|
13
|
-
get document():
|
|
13
|
+
get document(): Document<RuleConfigValue, unknown> | ParserError;
|
|
14
14
|
verify(fix?: boolean): Promise<Violation[]>;
|
|
15
15
|
setCode(sourceCode: string): void;
|
|
16
16
|
update({ parser, ruleset, rules, locale, schemas, parserOptions }: Partial<MLFabric>): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type MLDOMAbstractElement from '../tokens/abstract-element';
|
|
2
2
|
export declare type Specificity = [number, number, number];
|
|
3
3
|
export declare function createSelector(selector: string, tagNameCaseSensitive?: boolean): Selector;
|
|
4
|
-
export declare function compareSpecificity(a: Specificity, b: Specificity):
|
|
4
|
+
export declare function compareSpecificity(a: Specificity, b: Specificity): 0 | 1 | -1;
|
|
5
5
|
declare type TargetElement = MLDOMAbstractElement<any, any>;
|
|
6
6
|
declare class Selector {
|
|
7
7
|
#private;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MLElement } from '../node/element';
|
|
2
|
+
import type { MLNode } from '../node/node';
|
|
3
|
+
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
|
|
7
|
+
*/
|
|
8
|
+
export declare function before<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
|
|
12
|
+
*/
|
|
13
|
+
export declare function after<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
|
|
17
|
+
*/
|
|
18
|
+
export declare function replaceWith<T extends RuleConfigValue, O = null>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
|
|
22
|
+
*/
|
|
23
|
+
export declare function remove<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): void;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
|
|
27
|
+
*/
|
|
28
|
+
export declare function previousElementSibling<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): MLElement<T, O> | null;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
|
|
32
|
+
*/
|
|
33
|
+
export declare function nextElementSibling<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): MLElement<T, O> | null;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
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"));
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
|
|
9
|
+
*/
|
|
10
|
+
function before(node, ...additionalNodes) {
|
|
11
|
+
throw new unexpected_call_error_1.default('Not supported "before" method');
|
|
12
|
+
}
|
|
13
|
+
exports.before = before;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
|
|
17
|
+
*/
|
|
18
|
+
function after(node, ...additionalNodes) {
|
|
19
|
+
throw new unexpected_call_error_1.default('Not supported "after" method');
|
|
20
|
+
}
|
|
21
|
+
exports.after = after;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
|
|
25
|
+
*/
|
|
26
|
+
function replaceWith(node, ...additionalNodes) {
|
|
27
|
+
throw new unexpected_call_error_1.default('Not supported "replaceWith" method');
|
|
28
|
+
}
|
|
29
|
+
exports.replaceWith = replaceWith;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
|
|
33
|
+
*/
|
|
34
|
+
function remove(node) {
|
|
35
|
+
throw new unexpected_call_error_1.default('Not supported "remove" method');
|
|
36
|
+
}
|
|
37
|
+
exports.remove = remove;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
|
|
41
|
+
*/
|
|
42
|
+
function previousElementSibling(node) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
let prevNode = node.prevNode;
|
|
45
|
+
while (prevNode) {
|
|
46
|
+
if (((node.parentNode === null && prevNode.parentNode === null) ||
|
|
47
|
+
((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = prevNode.parentNode) === null || _b === void 0 ? void 0 : _b.uuid)) &&
|
|
48
|
+
prevNode.is(prevNode.ELEMENT_NODE)) {
|
|
49
|
+
return prevNode;
|
|
50
|
+
}
|
|
51
|
+
prevNode = prevNode.prevNode;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
exports.previousElementSibling = previousElementSibling;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
|
|
59
|
+
*/
|
|
60
|
+
function nextElementSibling(node) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
let nextNode = node.nextNode;
|
|
63
|
+
while (nextNode) {
|
|
64
|
+
if (((node.parentNode === null && nextNode.parentNode === null) ||
|
|
65
|
+
((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = nextNode.parentNode) === null || _b === void 0 ? void 0 : _b.uuid)) &&
|
|
66
|
+
nextNode.is(nextNode.ELEMENT_NODE)) {
|
|
67
|
+
return nextNode;
|
|
68
|
+
}
|
|
69
|
+
nextNode = nextNode.nextNode;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
exports.nextElementSibling = nextElementSibling;
|
|
@@ -0,0 +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 = null>(node: MLNode<T, O>): HTMLCollectionOf<MLElement<T, O>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChildren = void 0;
|
|
4
|
+
const node_list_1 = require("../node/node-list");
|
|
5
|
+
function getChildren(node) {
|
|
6
|
+
return (0, node_list_1.toHTMLCollection)(Array.from(node.childNodes).filter((child) => {
|
|
7
|
+
return child.nodeType === child.ELEMENT_NODE;
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
exports.getChildren = getChildren;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { MLElement } from './element';
|
|
2
|
+
import type { AttributeNodeType } from './types';
|
|
3
|
+
import type { MLASTAttr } from '@markuplint/ml-ast';
|
|
4
|
+
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
5
|
+
import { MLToken } from '../token/token';
|
|
6
|
+
import { MLNode } from './node';
|
|
7
|
+
export declare class MLAttr<T extends RuleConfigValue, O = null> extends MLNode<T, O, MLASTAttr> implements Attr {
|
|
8
|
+
#private;
|
|
9
|
+
readonly candidate?: string;
|
|
10
|
+
readonly endQuote: MLToken | null;
|
|
11
|
+
readonly equal: MLToken | null;
|
|
12
|
+
readonly isDirective?: true;
|
|
13
|
+
readonly isDuplicatable: boolean;
|
|
14
|
+
readonly isDynamicValue?: true;
|
|
15
|
+
readonly nameNode: MLToken | null;
|
|
16
|
+
/**
|
|
17
|
+
* @implements DOM API: `Attr`
|
|
18
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
|
|
19
|
+
*/
|
|
20
|
+
readonly ownerElement: MLElement<T, O>;
|
|
21
|
+
readonly spacesAfterEqual: MLToken | null;
|
|
22
|
+
readonly spacesBeforeEqual: MLToken | null;
|
|
23
|
+
readonly spacesBeforeName: MLToken | null;
|
|
24
|
+
readonly startQuote: MLToken | null;
|
|
25
|
+
readonly valueNode: MLToken | null;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
|
|
28
|
+
*
|
|
29
|
+
* @default "string"
|
|
30
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
31
|
+
*/
|
|
32
|
+
readonly valueType: 'string' | 'number' | 'boolean' | 'code';
|
|
33
|
+
/**
|
|
34
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
35
|
+
*
|
|
36
|
+
* @unsupported
|
|
37
|
+
* @implements DOM API: `Attr`
|
|
38
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
|
|
39
|
+
*/
|
|
40
|
+
get localName(): string;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @implements DOM API: `Attr`
|
|
44
|
+
* @see https://dom.spec.whatwg.org/#dom-attr-name
|
|
45
|
+
*/
|
|
46
|
+
get name(): string;
|
|
47
|
+
/**
|
|
48
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
49
|
+
*
|
|
50
|
+
* @unsupported
|
|
51
|
+
* @implements DOM API: `Attr`
|
|
52
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
|
|
53
|
+
*/
|
|
54
|
+
get namespaceURI(): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Returns a string appropriate for the type of node as `Attr`
|
|
57
|
+
*
|
|
58
|
+
* @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
|
|
59
|
+
*/
|
|
60
|
+
get nodeName(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Returns a number appropriate for the type of `Attr`
|
|
63
|
+
*/
|
|
64
|
+
get nodeType(): AttributeNodeType;
|
|
65
|
+
get nodeValue(): string;
|
|
66
|
+
/**
|
|
67
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
68
|
+
*
|
|
69
|
+
* @unsupported
|
|
70
|
+
* @implements DOM API: `Attr`
|
|
71
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
|
|
72
|
+
*/
|
|
73
|
+
get prefix(): string | null;
|
|
74
|
+
/**
|
|
75
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
76
|
+
*/
|
|
77
|
+
get rule(): import("@markuplint/ml-config").RuleInfo<T, O>;
|
|
78
|
+
/**
|
|
79
|
+
* @implements DOM API: `Attr`
|
|
80
|
+
* @see https://dom.spec.whatwg.org/#dom-attr-specified
|
|
81
|
+
*/
|
|
82
|
+
get specified(): true;
|
|
83
|
+
/**
|
|
84
|
+
* @implements DOM API: `Attr`
|
|
85
|
+
* @see https://dom.spec.whatwg.org/#dom-attr-value
|
|
86
|
+
*/
|
|
87
|
+
get value(): string;
|
|
88
|
+
constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
|
|
89
|
+
/**
|
|
90
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
91
|
+
*/
|
|
92
|
+
toNormalizeString(): string;
|
|
93
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _MLAttr_potentialName, _MLAttr_potentialValue;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MLAttr = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const token_1 = require("../token/token");
|
|
7
|
+
const node_1 = require("./node");
|
|
8
|
+
const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
|
|
9
|
+
class MLAttr extends node_1.MLNode {
|
|
10
|
+
constructor(astToken, ownElement) {
|
|
11
|
+
var _a;
|
|
12
|
+
super(astToken, ownElement.ownerMLDocument);
|
|
13
|
+
_MLAttr_potentialName.set(this, void 0);
|
|
14
|
+
_MLAttr_potentialValue.set(this, void 0);
|
|
15
|
+
this.endQuote = null;
|
|
16
|
+
this.equal = null;
|
|
17
|
+
this.nameNode = null;
|
|
18
|
+
this.spacesAfterEqual = null;
|
|
19
|
+
this.spacesBeforeEqual = null;
|
|
20
|
+
this.spacesBeforeName = null;
|
|
21
|
+
this.startQuote = null;
|
|
22
|
+
this.valueNode = null;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
|
|
25
|
+
*
|
|
26
|
+
* @default "string"
|
|
27
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
28
|
+
*/
|
|
29
|
+
this.valueType = 'string';
|
|
30
|
+
if (this._astToken.type === 'html-attr') {
|
|
31
|
+
this.spacesBeforeName = new token_1.MLToken(this._astToken.spacesBeforeName);
|
|
32
|
+
this.nameNode = new token_1.MLToken(this._astToken.name);
|
|
33
|
+
this.spacesBeforeEqual = new token_1.MLToken(this._astToken.spacesBeforeEqual);
|
|
34
|
+
this.equal = new token_1.MLToken(this._astToken.equal);
|
|
35
|
+
this.spacesAfterEqual = new token_1.MLToken(this._astToken.spacesAfterEqual);
|
|
36
|
+
this.startQuote = new token_1.MLToken(this._astToken.startQuote);
|
|
37
|
+
this.valueNode = new token_1.MLToken(this._astToken.value);
|
|
38
|
+
this.endQuote = new token_1.MLToken(this._astToken.endQuote);
|
|
39
|
+
this.isDynamicValue = this._astToken.isDynamicValue;
|
|
40
|
+
this.isDirective = this._astToken.isDirective;
|
|
41
|
+
this.candidate = this._astToken.candidate;
|
|
42
|
+
tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName || ((_a = this.nameNode) === null || _a === void 0 ? void 0 : _a.raw) || '', "f");
|
|
43
|
+
tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.value.raw || '', "f");
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.valueType = this._astToken.valueType;
|
|
47
|
+
this.isDuplicatable = this._astToken.isDuplicatable;
|
|
48
|
+
tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName, "f");
|
|
49
|
+
tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.potentialValue, "f");
|
|
50
|
+
}
|
|
51
|
+
this.ownerElement = ownElement;
|
|
52
|
+
this.isDuplicatable = this._astToken.isDuplicatable;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
56
|
+
*
|
|
57
|
+
* @unsupported
|
|
58
|
+
* @implements DOM API: `Attr`
|
|
59
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
|
|
60
|
+
*/
|
|
61
|
+
get localName() {
|
|
62
|
+
throw new unexpected_call_error_1.default('Not supported "localname" property');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @implements DOM API: `Attr`
|
|
67
|
+
* @see https://dom.spec.whatwg.org/#dom-attr-name
|
|
68
|
+
*/
|
|
69
|
+
get name() {
|
|
70
|
+
return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialName, "f");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
74
|
+
*
|
|
75
|
+
* @unsupported
|
|
76
|
+
* @implements DOM API: `Attr`
|
|
77
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
|
|
78
|
+
*/
|
|
79
|
+
get namespaceURI() {
|
|
80
|
+
throw new unexpected_call_error_1.default('Not supported "namespaceURI" property');
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns a string appropriate for the type of node as `Attr`
|
|
84
|
+
*
|
|
85
|
+
* @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
|
|
86
|
+
*/
|
|
87
|
+
get nodeName() {
|
|
88
|
+
return this.name;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns a number appropriate for the type of `Attr`
|
|
92
|
+
*/
|
|
93
|
+
get nodeType() {
|
|
94
|
+
return this.ATTRIBUTE_NODE;
|
|
95
|
+
}
|
|
96
|
+
get nodeValue() {
|
|
97
|
+
return this.value;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
101
|
+
*
|
|
102
|
+
* @unsupported
|
|
103
|
+
* @implements DOM API: `Attr`
|
|
104
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
|
|
105
|
+
*/
|
|
106
|
+
get prefix() {
|
|
107
|
+
throw new unexpected_call_error_1.default('Not supported "prefix" property');
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
111
|
+
*/
|
|
112
|
+
get rule() {
|
|
113
|
+
return this.ownerElement.rule;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @implements DOM API: `Attr`
|
|
117
|
+
* @see https://dom.spec.whatwg.org/#dom-attr-specified
|
|
118
|
+
*/
|
|
119
|
+
get specified() {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @implements DOM API: `Attr`
|
|
124
|
+
* @see https://dom.spec.whatwg.org/#dom-attr-value
|
|
125
|
+
*/
|
|
126
|
+
get value() {
|
|
127
|
+
return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
131
|
+
*/
|
|
132
|
+
toNormalizeString() {
|
|
133
|
+
if (this.nameNode && this.equal && this.startQuote && this.valueNode && this.endQuote) {
|
|
134
|
+
return (this.nameNode.originRaw +
|
|
135
|
+
this.equal.originRaw +
|
|
136
|
+
this.startQuote.originRaw +
|
|
137
|
+
this.valueNode.originRaw +
|
|
138
|
+
this.endQuote.originRaw);
|
|
139
|
+
}
|
|
140
|
+
return this.raw;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.MLAttr = MLAttr;
|
|
144
|
+
_MLAttr_potentialName = new WeakMap(), _MLAttr_potentialValue = new WeakMap();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { MLDocument } from './document';
|
|
2
|
+
import type { MLElement } from './element';
|
|
3
|
+
import type { MarkuplintPreprocessorBlockType } from './types';
|
|
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 = null> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
|
|
8
|
+
readonly isTransparent: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a string appropriate for the type of node as `MLBlock`
|
|
11
|
+
*
|
|
12
|
+
* @implements `@markuplint/ml-core` API: `MLBlock`
|
|
13
|
+
*/
|
|
14
|
+
get nodeName(): "#ml-block";
|
|
15
|
+
/**
|
|
16
|
+
* Returns a number appropriate for the type of `MLBlock`
|
|
17
|
+
*
|
|
18
|
+
* @implements `@markuplint/ml-core` API: `MLBlock`
|
|
19
|
+
*/
|
|
20
|
+
get nodeType(): MarkuplintPreprocessorBlockType;
|
|
21
|
+
constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
|
|
22
|
+
/**
|
|
23
|
+
* @implements DOM API: `ChildNode`
|
|
24
|
+
*/
|
|
25
|
+
after(...nodes: (string | MLElement<any, any>)[]): void;
|
|
26
|
+
/**
|
|
27
|
+
* @implements DOM API: `ChildNode`
|
|
28
|
+
*/
|
|
29
|
+
before(...nodes: (string | MLElement<any, any>)[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* @implements DOM API: `ChildNode`
|
|
32
|
+
*/
|
|
33
|
+
remove(): void;
|
|
34
|
+
/**
|
|
35
|
+
* @implements DOM API: `ChildNode`
|
|
36
|
+
*/
|
|
37
|
+
replaceWith(...nodes: (string | MLElement<any, any>)[]): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MLBlock = void 0;
|
|
4
|
+
const child_node_methods_1 = require("../manipulations/child-node-methods");
|
|
5
|
+
const node_1 = require("./node");
|
|
6
|
+
class MLBlock extends node_1.MLNode {
|
|
7
|
+
constructor(astNode, document) {
|
|
8
|
+
super(astNode, document);
|
|
9
|
+
// TODO:
|
|
10
|
+
this.isTransparent = true;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns a string appropriate for the type of node as `MLBlock`
|
|
14
|
+
*
|
|
15
|
+
* @implements `@markuplint/ml-core` API: `MLBlock`
|
|
16
|
+
*/
|
|
17
|
+
get nodeName() {
|
|
18
|
+
return '#ml-block';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns a number appropriate for the type of `MLBlock`
|
|
22
|
+
*
|
|
23
|
+
* @implements `@markuplint/ml-core` API: `MLBlock`
|
|
24
|
+
*/
|
|
25
|
+
get nodeType() {
|
|
26
|
+
return this.MARKUPLINT_PREPROCESSOR_BLOCK;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @implements DOM API: `ChildNode`
|
|
30
|
+
*/
|
|
31
|
+
after(...nodes) {
|
|
32
|
+
(0, child_node_methods_1.after)(this, ...nodes);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @implements DOM API: `ChildNode`
|
|
36
|
+
*/
|
|
37
|
+
before(...nodes) {
|
|
38
|
+
(0, child_node_methods_1.before)(this, ...nodes);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @implements DOM API: `ChildNode`
|
|
42
|
+
*/
|
|
43
|
+
remove() {
|
|
44
|
+
(0, child_node_methods_1.remove)(this);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @implements DOM API: `ChildNode`
|
|
48
|
+
*/
|
|
49
|
+
replaceWith(...nodes) {
|
|
50
|
+
(0, child_node_methods_1.replaceWith)(this, ...nodes);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.MLBlock = MLBlock;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { MLElement } from './element';
|
|
2
|
+
import type { MLASTAbstructNode } from '@markuplint/ml-ast';
|
|
3
|
+
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
+
import { MLNode } from './node';
|
|
5
|
+
export declare abstract class MLCharacterData<T extends RuleConfigValue, O = null, A extends MLASTAbstructNode = MLASTAbstructNode> extends MLNode<T, O, A> implements CharacterData {
|
|
6
|
+
/**
|
|
7
|
+
* @implements DOM API: `CharacterData`
|
|
8
|
+
* @see https://dom.spec.whatwg.org/#dom-characterdata-data
|
|
9
|
+
*/
|
|
10
|
+
get data(): string;
|
|
11
|
+
/**
|
|
12
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
13
|
+
*
|
|
14
|
+
* @unsupported
|
|
15
|
+
* @implements DOM API: `CharacterData`
|
|
16
|
+
* @see https://dom.spec.whatwg.org/#dom-characterdata-length
|
|
17
|
+
*/
|
|
18
|
+
get length(): number;
|
|
19
|
+
/**
|
|
20
|
+
* The element immediately following the specified one in its parent's children list.
|
|
21
|
+
*
|
|
22
|
+
* @readonly
|
|
23
|
+
* @implements DOM API: `CharacterData`
|
|
24
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A1
|
|
25
|
+
*/
|
|
26
|
+
get nextElementSibling(): MLElement<T, O> | null;
|
|
27
|
+
get nodeValue(): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* The element immediately prior the specified one in its parent's children list.
|
|
30
|
+
*
|
|
31
|
+
* @readonly
|
|
32
|
+
* @implements DOM API: `CharacterData`
|
|
33
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A1
|
|
34
|
+
*/
|
|
35
|
+
get previousElementSibling(): MLElement<T, O> | null;
|
|
36
|
+
/**
|
|
37
|
+
* @implements DOM API: `CharacterData`
|
|
38
|
+
*/
|
|
39
|
+
after(...nodes: (string | MLElement<any, any>)[]): void;
|
|
40
|
+
appendData(data: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* @implements DOM API: `CharacterData`
|
|
43
|
+
*/
|
|
44
|
+
before(...nodes: (string | MLElement<any, any>)[]): void;
|
|
45
|
+
deleteData(offset: number, count: number): void;
|
|
46
|
+
insertData(offset: number, data: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* @implements DOM API: `CharacterData`
|
|
49
|
+
*/
|
|
50
|
+
remove(): void;
|
|
51
|
+
replaceData(offset: number, count: number, data: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* @implements DOM API: `CharacterData`
|
|
54
|
+
*/
|
|
55
|
+
replaceWith(...nodes: (string | MLElement<any, any>)[]): void;
|
|
56
|
+
substringData(offset: number, count: number): string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MLCharacterData = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_node_methods_1 = require("../manipulations/child-node-methods");
|
|
6
|
+
const node_1 = require("./node");
|
|
7
|
+
const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
|
|
8
|
+
class MLCharacterData extends node_1.MLNode {
|
|
9
|
+
/**
|
|
10
|
+
* @implements DOM API: `CharacterData`
|
|
11
|
+
* @see https://dom.spec.whatwg.org/#dom-characterdata-data
|
|
12
|
+
*/
|
|
13
|
+
get data() {
|
|
14
|
+
// TODO:
|
|
15
|
+
return this.raw;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
19
|
+
*
|
|
20
|
+
* @unsupported
|
|
21
|
+
* @implements DOM API: `CharacterData`
|
|
22
|
+
* @see https://dom.spec.whatwg.org/#dom-characterdata-length
|
|
23
|
+
*/
|
|
24
|
+
get length() {
|
|
25
|
+
throw new unexpected_call_error_1.default('Not supported "length" property');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The element immediately following the specified one in its parent's children list.
|
|
29
|
+
*
|
|
30
|
+
* @readonly
|
|
31
|
+
* @implements DOM API: `CharacterData`
|
|
32
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A1
|
|
33
|
+
*/
|
|
34
|
+
get nextElementSibling() {
|
|
35
|
+
return (0, child_node_methods_1.nextElementSibling)(this);
|
|
36
|
+
}
|
|
37
|
+
get nodeValue() {
|
|
38
|
+
return this.data;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The element immediately prior the specified one in its parent's children list.
|
|
42
|
+
*
|
|
43
|
+
* @readonly
|
|
44
|
+
* @implements DOM API: `CharacterData`
|
|
45
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A1
|
|
46
|
+
*/
|
|
47
|
+
get previousElementSibling() {
|
|
48
|
+
return (0, child_node_methods_1.previousElementSibling)(this);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @implements DOM API: `CharacterData`
|
|
52
|
+
*/
|
|
53
|
+
after(...nodes) {
|
|
54
|
+
(0, child_node_methods_1.after)(this, ...nodes);
|
|
55
|
+
}
|
|
56
|
+
// TODO
|
|
57
|
+
appendData(data) { }
|
|
58
|
+
/**
|
|
59
|
+
* @implements DOM API: `CharacterData`
|
|
60
|
+
*/
|
|
61
|
+
before(...nodes) {
|
|
62
|
+
(0, child_node_methods_1.before)(this, ...nodes);
|
|
63
|
+
}
|
|
64
|
+
// TODO
|
|
65
|
+
deleteData(offset, count) { }
|
|
66
|
+
// TODO
|
|
67
|
+
insertData(offset, data) { }
|
|
68
|
+
/**
|
|
69
|
+
* @implements DOM API: `CharacterData`
|
|
70
|
+
*/
|
|
71
|
+
remove() {
|
|
72
|
+
(0, child_node_methods_1.remove)(this);
|
|
73
|
+
}
|
|
74
|
+
// TODO
|
|
75
|
+
replaceData(offset, count, data) { }
|
|
76
|
+
/**
|
|
77
|
+
* @implements DOM API: `CharacterData`
|
|
78
|
+
*/
|
|
79
|
+
replaceWith(...nodes) {
|
|
80
|
+
(0, child_node_methods_1.replaceWith)(this, ...nodes);
|
|
81
|
+
}
|
|
82
|
+
// TODO
|
|
83
|
+
substringData(offset, count) {
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.MLCharacterData = MLCharacterData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MLBlock } from './block';
|
|
2
|
+
import type { MLCharacterData } from './character-data';
|
|
3
|
+
import type { MLDocumentType } from './document-type';
|
|
4
|
+
import type { MLElement } from './element';
|
|
5
|
+
import type { MLNode } from './node';
|
|
6
|
+
import type { MLText } from './text';
|
|
7
|
+
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
8
|
+
export declare type MLChildNode<T extends RuleConfigValue, O = null> = MLDocumentType<T, O> | MLCharacterData<T, O> | MLText<T, O> | MLElement<T, O> | MLBlock<T, O>;
|
|
9
|
+
export declare function isChildNode<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): node is MLChildNode<T, O>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isChildNode = void 0;
|
|
4
|
+
function isChildNode(node) {
|
|
5
|
+
return (node.is(node.DOCUMENT_TYPE_NODE) ||
|
|
6
|
+
node.is(node.TEXT_NODE) ||
|
|
7
|
+
node.is(node.ELEMENT_NODE) ||
|
|
8
|
+
node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK));
|
|
9
|
+
}
|
|
10
|
+
exports.isChildNode = isChildNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CommentNodeType } from './types';
|
|
2
|
+
import type { MLASTComment } from '@markuplint/ml-ast';
|
|
3
|
+
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
+
import { MLCharacterData } from './character-data';
|
|
5
|
+
export declare class MLComment<T extends RuleConfigValue, O = null> extends MLCharacterData<T, O, MLASTComment> implements Comment {
|
|
6
|
+
/**
|
|
7
|
+
* Returns a string appropriate for the type of node as `Attr`
|
|
8
|
+
*
|
|
9
|
+
* @see https://dom.spec.whatwg.org/#ref-for-exclusive-text-node%E2%91%A0
|
|
10
|
+
*/
|
|
11
|
+
get nodeName(): "#comment";
|
|
12
|
+
/**
|
|
13
|
+
* Returns a number appropriate for the type of `Comment`
|
|
14
|
+
*/
|
|
15
|
+
get nodeType(): CommentNodeType;
|
|
16
|
+
get textContent(): string | null;
|
|
17
|
+
}
|