@markuplint/ml-core 3.0.0-alpha.0 → 3.0.0-alpha.2
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-core.js +12 -7
- package/lib/ml-dom/helper/accname.d.ts +2 -1
- package/lib/ml-dom/helper/accname.js +51 -2
- package/lib/ml-dom/helper/create-node.d.ts +2 -2
- package/lib/ml-dom/helper/create-node.js +1 -1
- package/lib/ml-dom/helper/debug.js +1 -1
- package/lib/ml-dom/helper/getIndent.d.ts +1 -1
- package/lib/ml-dom/node/attr.d.ts +5 -5
- package/lib/ml-dom/node/attr.js +9 -9
- package/lib/ml-dom/node/block.d.ts +1 -1
- package/lib/ml-dom/node/character-data.d.ts +2 -2
- package/lib/ml-dom/node/document-fragment.d.ts +2 -2
- package/lib/ml-dom/node/document-type.d.ts +1 -1
- package/lib/ml-dom/node/document.d.ts +28 -19
- package/lib/ml-dom/node/document.js +40 -17
- package/lib/ml-dom/node/dom-token-list.d.ts +2 -2
- package/lib/ml-dom/node/dom-token-list.js +6 -6
- package/lib/ml-dom/node/element.d.ts +53 -30
- package/lib/ml-dom/node/element.js +203 -50
- package/lib/ml-dom/node/node-list.d.ts +1 -1
- package/lib/ml-dom/node/node-store.d.ts +3 -3
- package/lib/ml-dom/node/node.d.ts +19 -12
- package/lib/ml-dom/node/node.js +35 -26
- package/lib/ml-dom/node/parent-node.d.ts +2 -2
- package/lib/ml-dom/node/types.d.ts +13 -3
- package/lib/ml-dom/token/token.d.ts +1 -1
- package/lib/ml-rule/ml-rule-context.d.ts +2 -1
- package/lib/ml-rule/ml-rule-context.js +19 -2
- package/lib/ml-rule/ml-rule.d.ts +4 -4
- package/lib/ml-rule/ml-rule.js +4 -4
- package/lib/ml-rule/types.d.ts +1 -1
- package/lib/test/index.d.ts +2 -1
- package/lib/test/index.js +5 -3
- package/lib/types.d.ts +3 -2
- package/package.json +11 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/ml-dom/document.d.ts +0 -94
- package/lib/ml-dom/document.js +0 -273
- package/lib/ml-dom/helper/index.d.ts +0 -4
- package/lib/ml-dom/helper/index.js +0 -12
- package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -52
- package/lib/ml-dom/helper/mapped-nodes.js +0 -2
- package/lib/ml-dom/helper/match-selector.d.ts +0 -20
- package/lib/ml-dom/helper/match-selector.js +0 -233
- package/lib/ml-dom/helper/node-store.d.ts +0 -12
- package/lib/ml-dom/helper/node-store.js +0 -28
- package/lib/ml-dom/helper/selector.d.ts +0 -11
- package/lib/ml-dom/helper/selector.js +0 -549
- package/lib/ml-dom/rule-mapper.d.ts +0 -16
- package/lib/ml-dom/rule-mapper.js +0 -57
- package/lib/ml-dom/tokens/abstract-element.d.ts +0 -54
- package/lib/ml-dom/tokens/abstract-element.js +0 -249
- package/lib/ml-dom/tokens/attribute.d.ts +0 -42
- package/lib/ml-dom/tokens/attribute.js +0 -85
- package/lib/ml-dom/tokens/comment.d.ts +0 -12
- package/lib/ml-dom/tokens/comment.js +0 -15
- package/lib/ml-dom/tokens/doctype.d.ts +0 -18
- package/lib/ml-dom/tokens/doctype.js +0 -32
- package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -27
- package/lib/ml-dom/tokens/element-close-tag.js +0 -45
- package/lib/ml-dom/tokens/element.d.ts +0 -26
- package/lib/ml-dom/tokens/element.js +0 -66
- package/lib/ml-dom/tokens/index.d.ts +0 -10
- package/lib/ml-dom/tokens/index.js +0 -26
- package/lib/ml-dom/tokens/node.d.ts +0 -46
- package/lib/ml-dom/tokens/node.js +0 -126
- package/lib/ml-dom/tokens/omitted-element.d.ts +0 -13
- package/lib/ml-dom/tokens/omitted-element.js +0 -12
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
- package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -14
- package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
- package/lib/ml-dom/tokens/text.d.ts +0 -19
- package/lib/ml-dom/tokens/text.js +0 -26
- package/lib/ml-dom/tokens/token.d.ts +0 -16
- package/lib/ml-dom/tokens/token.js +0 -55
- package/lib/ml-dom/types.d.ts +0 -49
- package/lib/ml-dom/types.js +0 -2
- package/lib/selector/is-pure-html-element.d.ts +0 -1
- package/lib/selector/is-pure-html-element.js +0 -7
- package/lib/selector/match-selector.d.ts +0 -14
- package/lib/selector/match-selector.js +0 -230
- package/lib/selector/selector.d.ts +0 -9
- package/lib/selector/selector.js +0 -561
package/lib/ml-core.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare type MLCoreParams = {
|
|
|
9
9
|
} & MLFabric;
|
|
10
10
|
export declare class MLCore {
|
|
11
11
|
#private;
|
|
12
|
+
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, }: MLCoreParams);
|
|
12
13
|
get document(): ParserError | Document<RuleConfigValue, unknown>;
|
|
13
|
-
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, filename, debug }: MLCoreParams);
|
|
14
14
|
setCode(sourceCode: string): void;
|
|
15
15
|
update({ parser, ruleset, rules, locale, schemas, parserOptions }: Partial<MLFabric>): void;
|
|
16
16
|
verify(fix?: boolean): Promise<Violation[]>;
|
package/lib/ml-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _MLCore_ast, _MLCore_document, _MLCore_filename,
|
|
2
|
+
var _MLCore_ast, _MLCore_document, _MLCore_filename, _MLCore_locale, _MLCore_parser, _MLCore_parserOptions, _MLCore_pretenders, _MLCore_rules, _MLCore_ruleset, _MLCore_schemas, _MLCore_sourceCode;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MLCore = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -8,14 +8,15 @@ const debug_1 = require("./debug");
|
|
|
8
8
|
const ml_dom_1 = require("./ml-dom");
|
|
9
9
|
const resultLog = debug_1.log.extend('result');
|
|
10
10
|
class MLCore {
|
|
11
|
-
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, filename, debug }) {
|
|
11
|
+
constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, }) {
|
|
12
12
|
var _a, _b, _c;
|
|
13
13
|
_MLCore_ast.set(this, null);
|
|
14
14
|
_MLCore_document.set(this, void 0);
|
|
15
15
|
_MLCore_filename.set(this, void 0);
|
|
16
|
-
_MLCore_ignoreFrontMatter.set(this, void 0);
|
|
17
16
|
_MLCore_locale.set(this, void 0);
|
|
18
17
|
_MLCore_parser.set(this, void 0);
|
|
18
|
+
_MLCore_parserOptions.set(this, void 0);
|
|
19
|
+
_MLCore_pretenders.set(this, void 0);
|
|
19
20
|
_MLCore_rules.set(this, void 0);
|
|
20
21
|
_MLCore_ruleset.set(this, void 0);
|
|
21
22
|
_MLCore_schemas.set(this, void 0);
|
|
@@ -25,7 +26,7 @@ class MLCore {
|
|
|
25
26
|
}
|
|
26
27
|
tslib_1.__classPrivateFieldSet(this, _MLCore_parser, parser, "f");
|
|
27
28
|
tslib_1.__classPrivateFieldSet(this, _MLCore_sourceCode, sourceCode, "f");
|
|
28
|
-
tslib_1.__classPrivateFieldSet(this,
|
|
29
|
+
tslib_1.__classPrivateFieldSet(this, _MLCore_parserOptions, parserOptions, "f");
|
|
29
30
|
tslib_1.__classPrivateFieldSet(this, _MLCore_ruleset, {
|
|
30
31
|
rules: (_a = ruleset.rules) !== null && _a !== void 0 ? _a : {},
|
|
31
32
|
nodeRules: (_b = ruleset.nodeRules) !== null && _b !== void 0 ? _b : [],
|
|
@@ -35,6 +36,7 @@ class MLCore {
|
|
|
35
36
|
tslib_1.__classPrivateFieldSet(this, _MLCore_schemas, schemas, "f");
|
|
36
37
|
tslib_1.__classPrivateFieldSet(this, _MLCore_filename, filename, "f");
|
|
37
38
|
tslib_1.__classPrivateFieldSet(this, _MLCore_rules, rules, "f");
|
|
39
|
+
tslib_1.__classPrivateFieldSet(this, _MLCore_pretenders, pretenders, "f");
|
|
38
40
|
this._parse();
|
|
39
41
|
this._createDocument();
|
|
40
42
|
}
|
|
@@ -57,7 +59,9 @@ class MLCore {
|
|
|
57
59
|
tslib_1.__classPrivateFieldSet(this, _MLCore_rules, rules !== null && rules !== void 0 ? rules : tslib_1.__classPrivateFieldGet(this, _MLCore_rules, "f"), "f");
|
|
58
60
|
tslib_1.__classPrivateFieldSet(this, _MLCore_locale, locale !== null && locale !== void 0 ? locale : tslib_1.__classPrivateFieldGet(this, _MLCore_locale, "f"), "f");
|
|
59
61
|
tslib_1.__classPrivateFieldSet(this, _MLCore_schemas, schemas !== null && schemas !== void 0 ? schemas : tslib_1.__classPrivateFieldGet(this, _MLCore_schemas, "f"), "f");
|
|
60
|
-
if (parserOptions &&
|
|
62
|
+
if (parserOptions &&
|
|
63
|
+
(parserOptions.ignoreFrontMatter !== tslib_1.__classPrivateFieldGet(this, _MLCore_parserOptions, "f").ignoreFrontMatter ||
|
|
64
|
+
parserOptions.authoredElementName !== tslib_1.__classPrivateFieldGet(this, _MLCore_parserOptions, "f").authoredElementName)) {
|
|
61
65
|
this._parse();
|
|
62
66
|
}
|
|
63
67
|
this._createDocument();
|
|
@@ -130,6 +134,7 @@ class MLCore {
|
|
|
130
134
|
tslib_1.__classPrivateFieldSet(this, _MLCore_document, new ml_dom_1.Document(tslib_1.__classPrivateFieldGet(this, _MLCore_ast, "f"), tslib_1.__classPrivateFieldGet(this, _MLCore_ruleset, "f"), tslib_1.__classPrivateFieldGet(this, _MLCore_schemas, "f"), {
|
|
131
135
|
filename: tslib_1.__classPrivateFieldGet(this, _MLCore_filename, "f"),
|
|
132
136
|
endTag: tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f").endTag,
|
|
137
|
+
pretenders: tslib_1.__classPrivateFieldGet(this, _MLCore_pretenders, "f"),
|
|
133
138
|
}), "f");
|
|
134
139
|
}
|
|
135
140
|
catch (err) {
|
|
@@ -143,7 +148,7 @@ class MLCore {
|
|
|
143
148
|
}
|
|
144
149
|
_parse() {
|
|
145
150
|
try {
|
|
146
|
-
tslib_1.__classPrivateFieldSet(this, _MLCore_ast, tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f").parse(tslib_1.__classPrivateFieldGet(this, _MLCore_sourceCode, "f"),
|
|
151
|
+
tslib_1.__classPrivateFieldSet(this, _MLCore_ast, tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f").parse(tslib_1.__classPrivateFieldGet(this, _MLCore_sourceCode, "f"), tslib_1.__classPrivateFieldGet(this, _MLCore_parserOptions, "f")), "f");
|
|
147
152
|
}
|
|
148
153
|
catch (err) {
|
|
149
154
|
(0, debug_1.log)('Caught the parse error: %O', err);
|
|
@@ -158,4 +163,4 @@ class MLCore {
|
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
exports.MLCore = MLCore;
|
|
161
|
-
_MLCore_ast = new WeakMap(), _MLCore_document = new WeakMap(), _MLCore_filename = new WeakMap(),
|
|
166
|
+
_MLCore_ast = new WeakMap(), _MLCore_document = new WeakMap(), _MLCore_filename = new WeakMap(), _MLCore_locale = new WeakMap(), _MLCore_parser = new WeakMap(), _MLCore_parserOptions = new WeakMap(), _MLCore_pretenders = new WeakMap(), _MLCore_rules = new WeakMap(), _MLCore_ruleset = new WeakMap(), _MLCore_schemas = new WeakMap(), _MLCore_sourceCode = new WeakMap();
|
|
@@ -4,7 +4,35 @@ exports.getAccname = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const debug_1 = require("../../debug");
|
|
6
6
|
const accnameLog = debug_1.log.extend('accname');
|
|
7
|
-
function getAccname(el) {
|
|
7
|
+
function getAccname(el, version) {
|
|
8
|
+
let accname = safeGet(el);
|
|
9
|
+
if (accname) {
|
|
10
|
+
return accname;
|
|
11
|
+
}
|
|
12
|
+
accname = getAccnameFromPretender(el);
|
|
13
|
+
if (accname) {
|
|
14
|
+
return accname;
|
|
15
|
+
}
|
|
16
|
+
if (isHidden(el)) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
if (isFromContent(el, version)) {
|
|
20
|
+
return Array.from(el.childNodes)
|
|
21
|
+
.map(child => {
|
|
22
|
+
if (child.is(child.ELEMENT_NODE)) {
|
|
23
|
+
return getAccname(child, version);
|
|
24
|
+
}
|
|
25
|
+
if (child.is(child.TEXT_NODE)) {
|
|
26
|
+
return child.textContent || '';
|
|
27
|
+
}
|
|
28
|
+
return '';
|
|
29
|
+
})
|
|
30
|
+
.join('');
|
|
31
|
+
}
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
exports.getAccname = getAccname;
|
|
35
|
+
function safeGet(el) {
|
|
8
36
|
try {
|
|
9
37
|
const name = (0, ml_spec_1.getAccname)(el);
|
|
10
38
|
return name;
|
|
@@ -15,4 +43,25 @@ function getAccname(el) {
|
|
|
15
43
|
return '';
|
|
16
44
|
}
|
|
17
45
|
}
|
|
18
|
-
|
|
46
|
+
function getAccnameFromPretender(el) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
if (((_a = el.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' && ((_b = el.pretenderContext.aria) === null || _b === void 0 ? void 0 : _b.name)) {
|
|
49
|
+
if (typeof el.pretenderContext.aria.name === 'boolean') {
|
|
50
|
+
return 'some-name(Pretender Options)';
|
|
51
|
+
}
|
|
52
|
+
const attrName = el.pretenderContext.aria.name.fromAttr;
|
|
53
|
+
const attrValue = el.getAttributePretended(attrName);
|
|
54
|
+
if (attrValue) {
|
|
55
|
+
return attrValue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
function isHidden(el) {
|
|
61
|
+
return el.getAttribute('aria-hidden') === 'true' || el.hasAttribute('hidden');
|
|
62
|
+
}
|
|
63
|
+
function isFromContent(el, version) {
|
|
64
|
+
var _a;
|
|
65
|
+
const role = (0, ml_spec_1.getComputedRole)(el.ownerMLDocument.specs, el, version);
|
|
66
|
+
return !!((_a = role.role) === null || _a === void 0 ? void 0 : _a.accessibleNameFromContent);
|
|
67
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MLDocument } from '../node/document';
|
|
2
2
|
import type { MappedNode } from '../node/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
4
4
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
5
|
-
export declare function createNode<N extends
|
|
5
|
+
export declare function createNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: N, document: MLDocument<T, O>): MappedNode<N, T, O>;
|
|
@@ -25,6 +25,6 @@ function createNode(astNode, document) {
|
|
|
25
25
|
return new text_1.MLText(_astNode, document);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
throw new TypeError(`Invalid AST node
|
|
28
|
+
throw new TypeError(`Invalid AST node types "${astNode.type}"`);
|
|
29
29
|
}
|
|
30
30
|
exports.createNode = createNode;
|
|
@@ -12,9 +12,9 @@ function nodeListToDebugMaps(nodeList, withAttr = false) {
|
|
|
12
12
|
r.push(tokenDebug(n));
|
|
13
13
|
if (n.is(n.ELEMENT_NODE)) {
|
|
14
14
|
r.push(` namespaceURI: ${!!n.namespaceURI}`);
|
|
15
|
+
r.push(` elementType: ${n.elementType}`);
|
|
15
16
|
r.push(` isInFragmentDocument: ${!!n.isInFragmentDocument}`);
|
|
16
17
|
r.push(` isForeignElement: ${!!n.isForeignElement}`);
|
|
17
|
-
r.push(` isCustomElement: ${!!n.isCustomElement}`);
|
|
18
18
|
if (withAttr) {
|
|
19
19
|
r.push(...attributesToDebugMaps(n.attributes)
|
|
20
20
|
.flat()
|
|
@@ -9,10 +9,10 @@ export declare function getIndent(node: MLNode<any, any>): MLDOMIndentation | nu
|
|
|
9
9
|
declare class MLDOMIndentation {
|
|
10
10
|
#private;
|
|
11
11
|
readonly line: number;
|
|
12
|
+
constructor(originTextNode: MLText<any, any>, raw: string, line: number, parentNode: MLNode<any, any>);
|
|
12
13
|
get raw(): string;
|
|
13
14
|
get type(): 'tab' | 'space' | 'mixed' | 'none';
|
|
14
15
|
get width(): number;
|
|
15
|
-
constructor(originTextNode: MLText<any, any>, raw: string, line: number, parentNode: MLNode<any, any>);
|
|
16
16
|
fix(raw: string): void;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -31,6 +31,7 @@ export declare class MLAttr<T extends RuleConfigValue, O = null> extends MLNode<
|
|
|
31
31
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
32
32
|
*/
|
|
33
33
|
readonly valueType: 'string' | 'number' | 'boolean' | 'code';
|
|
34
|
+
constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
|
|
34
35
|
/**
|
|
35
36
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
36
37
|
*
|
|
@@ -81,16 +82,15 @@ export declare class MLAttr<T extends RuleConfigValue, O = null> extends MLNode<
|
|
|
81
82
|
* @see https://dom.spec.whatwg.org/#dom-attr-specified
|
|
82
83
|
*/
|
|
83
84
|
get specified(): true;
|
|
85
|
+
/**
|
|
86
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
87
|
+
*/
|
|
88
|
+
get tokenList(): MLDomTokenList | null;
|
|
84
89
|
/**
|
|
85
90
|
* @implements DOM API: `Attr`
|
|
86
91
|
* @see https://dom.spec.whatwg.org/#dom-attr-value
|
|
87
92
|
*/
|
|
88
93
|
get value(): string;
|
|
89
|
-
/**
|
|
90
|
-
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
91
|
-
*/
|
|
92
|
-
get tokenList(): MLDomTokenList | null;
|
|
93
|
-
constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
|
|
94
94
|
/**
|
|
95
95
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
96
96
|
*/
|
package/lib/ml-dom/node/attr.js
CHANGED
|
@@ -12,13 +12,13 @@ class MLAttr extends node_1.MLNode {
|
|
|
12
12
|
constructor(astToken, ownElement) {
|
|
13
13
|
var _a;
|
|
14
14
|
super(astToken, ownElement.ownerMLDocument);
|
|
15
|
+
this.endQuote = null;
|
|
16
|
+
this.equal = null;
|
|
15
17
|
_MLAttr_localName.set(this, void 0);
|
|
18
|
+
this.nameNode = null;
|
|
16
19
|
_MLAttr_namespaceURI.set(this, void 0);
|
|
17
20
|
_MLAttr_potentialName.set(this, void 0);
|
|
18
21
|
_MLAttr_potentialValue.set(this, void 0);
|
|
19
|
-
this.endQuote = null;
|
|
20
|
-
this.equal = null;
|
|
21
|
-
this.nameNode = null;
|
|
22
22
|
this.spacesAfterEqual = null;
|
|
23
23
|
this.spacesBeforeEqual = null;
|
|
24
24
|
this.spacesBeforeName = null;
|
|
@@ -126,6 +126,12 @@ class MLAttr extends node_1.MLNode {
|
|
|
126
126
|
get specified() {
|
|
127
127
|
return true;
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
131
|
+
*/
|
|
132
|
+
get tokenList() {
|
|
133
|
+
return this.isDynamicValue ? null : new dom_token_list_1.MLDomTokenList(this.value, [this]);
|
|
134
|
+
}
|
|
129
135
|
/**
|
|
130
136
|
* @implements DOM API: `Attr`
|
|
131
137
|
* @see https://dom.spec.whatwg.org/#dom-attr-value
|
|
@@ -133,12 +139,6 @@ class MLAttr extends node_1.MLNode {
|
|
|
133
139
|
get value() {
|
|
134
140
|
return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
|
|
135
141
|
}
|
|
136
|
-
/**
|
|
137
|
-
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
138
|
-
*/
|
|
139
|
-
get tokenList() {
|
|
140
|
-
return this.isDynamicValue ? null : new dom_token_list_1.MLDomTokenList(this.value, [this]);
|
|
141
|
-
}
|
|
142
142
|
/**
|
|
143
143
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
144
144
|
*/
|
|
@@ -6,6 +6,7 @@ import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
|
6
6
|
import { MLNode } from './node';
|
|
7
7
|
export declare class MLBlock<T extends RuleConfigValue, O = null> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
|
|
8
8
|
readonly isTransparent: boolean;
|
|
9
|
+
constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
|
|
9
10
|
/**
|
|
10
11
|
* Returns a string appropriate for the type of node as `MLBlock`
|
|
11
12
|
*
|
|
@@ -18,7 +19,6 @@ export declare class MLBlock<T extends RuleConfigValue, O = null> extends MLNode
|
|
|
18
19
|
* @implements `@markuplint/ml-core` API: `MLBlock`
|
|
19
20
|
*/
|
|
20
21
|
get nodeType(): MarkuplintPreprocessorBlockType;
|
|
21
|
-
constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
|
|
22
22
|
/**
|
|
23
23
|
* @implements DOM API: `ChildNode`
|
|
24
24
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MLElement } from './element';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
3
3
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
import { MLNode } from './node';
|
|
5
|
-
export declare abstract class MLCharacterData<T extends RuleConfigValue, O = null, A extends
|
|
5
|
+
export declare abstract class MLCharacterData<T extends RuleConfigValue, O = null, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLNode<T, O, A> implements CharacterData {
|
|
6
6
|
/**
|
|
7
7
|
* @implements DOM API: `CharacterData`
|
|
8
8
|
* @see https://dom.spec.whatwg.org/#dom-characterdata-data
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DocumentFragmentNodeType } from './types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
3
3
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
import { MLParentNode } from './parent-node';
|
|
5
|
-
export declare class MLDocumentFragment<T extends RuleConfigValue, O = null> extends MLParentNode<T, O,
|
|
5
|
+
export declare class MLDocumentFragment<T extends RuleConfigValue, O = null> extends MLParentNode<T, O, MLASTAbstractNode> implements DocumentFragment {
|
|
6
6
|
/**
|
|
7
7
|
* Returns a string appropriate for the type of node as `DocumentFragment`
|
|
8
8
|
*
|
|
@@ -8,6 +8,7 @@ export declare class MLDocumentType<T extends RuleConfigValue, O = null> extends
|
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly publicId: string;
|
|
10
10
|
readonly systemId: string;
|
|
11
|
+
constructor(astNode: MLASTDoctype, document: MLDocument<T, O>);
|
|
11
12
|
/**
|
|
12
13
|
* Returns a string appropriate for the type of node as `DocumentType`
|
|
13
14
|
*
|
|
@@ -18,7 +19,6 @@ export declare class MLDocumentType<T extends RuleConfigValue, O = null> extends
|
|
|
18
19
|
* Returns a number appropriate for the type of `DocumentType`
|
|
19
20
|
*/
|
|
20
21
|
get nodeType(): DocumentTypeNodeType;
|
|
21
|
-
constructor(astNode: MLASTDoctype, document: MLDocument<T, O>);
|
|
22
22
|
/**
|
|
23
23
|
* @implements DOM API: `CharacterData`
|
|
24
24
|
*/
|
|
@@ -10,7 +10,7 @@ import type { MLNode } from './node';
|
|
|
10
10
|
import type { MLText } from './text';
|
|
11
11
|
import type { DocumentNodeType } from './types';
|
|
12
12
|
import type { MLASTDocument } from '@markuplint/ml-ast';
|
|
13
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
13
|
+
import type { Pretender, RuleConfigValue } from '@markuplint/ml-config';
|
|
14
14
|
import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
15
15
|
import { MLParentNode } from './parent-node';
|
|
16
16
|
export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLParentNode<T, O> implements Document {
|
|
@@ -39,6 +39,23 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
39
39
|
*
|
|
40
40
|
*/
|
|
41
41
|
readonly specs: Readonly<MLMLSpec>;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param ast node list of markuplint AST
|
|
45
|
+
* @param ruleset ruleset object
|
|
46
|
+
*/
|
|
47
|
+
constructor(ast: MLASTDocument, ruleset: Ruleset, schemas: readonly [MLMLSpec, ...ExtendedSpec[]], options?: {
|
|
48
|
+
filename?: string;
|
|
49
|
+
endTag?: 'xml' | 'omittable' | 'never';
|
|
50
|
+
pretenders?: Pretender[];
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
54
|
+
*
|
|
55
|
+
* @unsupported
|
|
56
|
+
* @implements DOM API: `Document`
|
|
57
|
+
*/
|
|
58
|
+
get URL(): string;
|
|
42
59
|
/**
|
|
43
60
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
44
61
|
*
|
|
@@ -46,6 +63,13 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
46
63
|
* @implements DOM API: `Document`
|
|
47
64
|
*/
|
|
48
65
|
get activeElement(): Element | null;
|
|
66
|
+
/**
|
|
67
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
68
|
+
*
|
|
69
|
+
* @unsupported
|
|
70
|
+
* @implements DOM API: `Document`
|
|
71
|
+
*/
|
|
72
|
+
get adoptedStyleSheets(): CSSStyleSheet[];
|
|
49
73
|
/**
|
|
50
74
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
51
75
|
*
|
|
@@ -1160,13 +1184,6 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1160
1184
|
* @implements DOM API: `Document`
|
|
1161
1185
|
*/
|
|
1162
1186
|
get title(): string;
|
|
1163
|
-
/**
|
|
1164
|
-
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1165
|
-
*
|
|
1166
|
-
* @unsupported
|
|
1167
|
-
* @implements DOM API: `Document`
|
|
1168
|
-
*/
|
|
1169
|
-
get URL(): string;
|
|
1170
1187
|
/**
|
|
1171
1188
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1172
1189
|
*
|
|
@@ -1182,15 +1199,6 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1182
1199
|
* @implements DOM API: `Document`
|
|
1183
1200
|
*/
|
|
1184
1201
|
get vlinkColor(): string;
|
|
1185
|
-
/**
|
|
1186
|
-
*
|
|
1187
|
-
* @param ast node list of markuplint AST
|
|
1188
|
-
* @param ruleset ruleset object
|
|
1189
|
-
*/
|
|
1190
|
-
constructor(ast: MLASTDocument, ruleset: Ruleset, schemas: readonly [MLMLSpec, ...ExtendedSpec[]], options?: {
|
|
1191
|
-
filename?: string;
|
|
1192
|
-
endTag?: 'xml' | 'omittable' | 'never';
|
|
1193
|
-
});
|
|
1194
1202
|
/**
|
|
1195
1203
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1196
1204
|
*
|
|
@@ -1297,14 +1305,14 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1297
1305
|
* @unsupported
|
|
1298
1306
|
* @implements DOM API: `Document`
|
|
1299
1307
|
*/
|
|
1300
|
-
|
|
1308
|
+
createNSResolver(nodeResolver: Node): XPathNSResolver;
|
|
1301
1309
|
/**
|
|
1302
1310
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1303
1311
|
*
|
|
1304
1312
|
* @unsupported
|
|
1305
1313
|
* @implements DOM API: `Document`
|
|
1306
1314
|
*/
|
|
1307
|
-
|
|
1315
|
+
createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter | null): NodeIterator;
|
|
1308
1316
|
/**
|
|
1309
1317
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1310
1318
|
*
|
|
@@ -1550,5 +1558,6 @@ export declare class MLDocument<T extends RuleConfigValue, O = null> extends MLP
|
|
|
1550
1558
|
* @implements DOM API: `Document`
|
|
1551
1559
|
*/
|
|
1552
1560
|
writeln(...text: string[]): void;
|
|
1561
|
+
private _pretending;
|
|
1553
1562
|
private _ruleMapping;
|
|
1554
1563
|
}
|
|
@@ -30,12 +30,12 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
|
|
34
|
-
_MLDocument_tokenList.set(this, null);
|
|
33
|
+
this.currentRule = null;
|
|
35
34
|
/**
|
|
36
35
|
*
|
|
37
36
|
*/
|
|
38
|
-
this
|
|
37
|
+
_MLDocument_filename.set(this, void 0);
|
|
38
|
+
_MLDocument_tokenList.set(this, null);
|
|
39
39
|
this.isFragment = ast.isFragment;
|
|
40
40
|
this.specs = (0, ml_spec_1.schemaToSpec)(schemas);
|
|
41
41
|
this.endTag = (_a = options === null || options === void 0 ? void 0 : options.endTag) !== null && _a !== void 0 ? _a : 'omittable';
|
|
@@ -49,8 +49,18 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
49
49
|
return (0, create_node_1.createNode)(astNode, this);
|
|
50
50
|
})
|
|
51
51
|
.filter((n) => !!n));
|
|
52
|
+
this._pretending(options === null || options === void 0 ? void 0 : options.pretenders);
|
|
52
53
|
this._ruleMapping(ruleset);
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
57
|
+
*
|
|
58
|
+
* @unsupported
|
|
59
|
+
* @implements DOM API: `Document`
|
|
60
|
+
*/
|
|
61
|
+
get URL() {
|
|
62
|
+
throw new unexpected_call_error_1.default('Not supported "URL" property');
|
|
63
|
+
}
|
|
54
64
|
/**
|
|
55
65
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
56
66
|
*
|
|
@@ -60,6 +70,15 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
60
70
|
get activeElement() {
|
|
61
71
|
throw new unexpected_call_error_1.default('Not supported "activeElement" property');
|
|
62
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
75
|
+
*
|
|
76
|
+
* @unsupported
|
|
77
|
+
* @implements DOM API: `Document`
|
|
78
|
+
*/
|
|
79
|
+
get adoptedStyleSheets() {
|
|
80
|
+
throw new unexpected_call_error_1.default('Not supported "adoptedStyleSheets" property');
|
|
81
|
+
}
|
|
63
82
|
/**
|
|
64
83
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
65
84
|
*
|
|
@@ -320,7 +339,7 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
320
339
|
* @implements DOM API: `Document`
|
|
321
340
|
*/
|
|
322
341
|
get fullscreenEnabled() {
|
|
323
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
342
|
+
throw new unexpected_call_error_1.default('Not supported "FullscreenEnabledURL" property');
|
|
324
343
|
}
|
|
325
344
|
/**
|
|
326
345
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -1481,15 +1500,6 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
1481
1500
|
get title() {
|
|
1482
1501
|
throw new unexpected_call_error_1.default('Not supported "title" property');
|
|
1483
1502
|
}
|
|
1484
|
-
/**
|
|
1485
|
-
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1486
|
-
*
|
|
1487
|
-
* @unsupported
|
|
1488
|
-
* @implements DOM API: `Document`
|
|
1489
|
-
*/
|
|
1490
|
-
get URL() {
|
|
1491
|
-
throw new unexpected_call_error_1.default('Not supported "URL" property');
|
|
1492
|
-
}
|
|
1493
1503
|
/**
|
|
1494
1504
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1495
1505
|
*
|
|
@@ -1643,8 +1653,8 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
1643
1653
|
* @unsupported
|
|
1644
1654
|
* @implements DOM API: `Document`
|
|
1645
1655
|
*/
|
|
1646
|
-
|
|
1647
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
1656
|
+
createNSResolver(nodeResolver) {
|
|
1657
|
+
throw new unexpected_call_error_1.default('Not supported "createNSResolver" method');
|
|
1648
1658
|
}
|
|
1649
1659
|
/**
|
|
1650
1660
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -1652,8 +1662,8 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
1652
1662
|
* @unsupported
|
|
1653
1663
|
* @implements DOM API: `Document`
|
|
1654
1664
|
*/
|
|
1655
|
-
|
|
1656
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
1665
|
+
createNodeIterator(root, whatToShow, filter) {
|
|
1666
|
+
throw new unexpected_call_error_1.default('Not supported "createNodeIterator" method');
|
|
1657
1667
|
}
|
|
1658
1668
|
/**
|
|
1659
1669
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -2001,6 +2011,19 @@ class MLDocument extends parent_node_1.MLParentNode {
|
|
|
2001
2011
|
writeln(...text) {
|
|
2002
2012
|
throw new unexpected_call_error_1.default('Not supported "writeln" method');
|
|
2003
2013
|
}
|
|
2014
|
+
_pretending(pretenders) {
|
|
2015
|
+
if (docLog.enabled) {
|
|
2016
|
+
docLog('Pretending: %O', pretenders);
|
|
2017
|
+
}
|
|
2018
|
+
if (!pretenders) {
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
for (const node of this.nodeList) {
|
|
2022
|
+
if (node.is(node.ELEMENT_NODE)) {
|
|
2023
|
+
node.pretending(pretenders);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2004
2027
|
_ruleMapping(ruleset) {
|
|
2005
2028
|
if (docLog.enabled) {
|
|
2006
2029
|
docLog('Rule Mapping: %O', Object.keys(ruleset.rules));
|
|
@@ -9,8 +9,8 @@ declare type Scope = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare class MLDomTokenList extends Array<string> implements DOMTokenList {
|
|
11
11
|
#private;
|
|
12
|
-
get value(): string;
|
|
13
12
|
constructor(tokens: string, ownerAttrs: MLAttr<any, any>[]);
|
|
13
|
+
get value(): string;
|
|
14
14
|
add(...tokens: string[]): void;
|
|
15
15
|
/**
|
|
16
16
|
* @implements `@markuplint/ml-core` API: `MLDomTokenList`
|
|
@@ -26,8 +26,8 @@ export declare class MLDomTokenList extends Array<string> implements DOMTokenLis
|
|
|
26
26
|
remove(...tokens: string[]): void;
|
|
27
27
|
replace(token: string, newToken: string): boolean;
|
|
28
28
|
supports(token: string): boolean;
|
|
29
|
-
toggle(token: string, force?: boolean): boolean;
|
|
30
29
|
toString(): string;
|
|
30
|
+
toggle(token: string, force?: boolean): boolean;
|
|
31
31
|
private _pick;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var _MLDomTokenList_origin, _MLDomTokenList_ownerAttrs, _MLDomTokenList_set;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MLDomTokenList = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -12,13 +12,13 @@ class MLDomTokenList extends Array {
|
|
|
12
12
|
.map(t => t.trim())
|
|
13
13
|
.filter(t => !!t);
|
|
14
14
|
super(...list);
|
|
15
|
-
_MLDomTokenList_set.set(this, void 0);
|
|
16
15
|
_MLDomTokenList_origin.set(this, void 0);
|
|
17
16
|
/**
|
|
18
17
|
* In some cases, an author specifies multiple attributes or directives.
|
|
19
18
|
* The reference is not always one.
|
|
20
19
|
*/
|
|
21
20
|
_MLDomTokenList_ownerAttrs.set(this, void 0);
|
|
21
|
+
_MLDomTokenList_set.set(this, void 0);
|
|
22
22
|
tslib_1.__classPrivateFieldSet(this, _MLDomTokenList_origin, tokens, "f");
|
|
23
23
|
tslib_1.__classPrivateFieldSet(this, _MLDomTokenList_ownerAttrs, ownerAttrs, "f");
|
|
24
24
|
tslib_1.__classPrivateFieldSet(this, _MLDomTokenList_set, new Set(list), "f");
|
|
@@ -99,12 +99,12 @@ class MLDomTokenList extends Array {
|
|
|
99
99
|
supports(token) {
|
|
100
100
|
throw new unexpected_call_error_1.default('Not supported "supports" method');
|
|
101
101
|
}
|
|
102
|
-
toggle(token, force) {
|
|
103
|
-
throw new unexpected_call_error_1.default('Not supported "toggle" method');
|
|
104
|
-
}
|
|
105
102
|
toString() {
|
|
106
103
|
return this.value;
|
|
107
104
|
}
|
|
105
|
+
toggle(token, force) {
|
|
106
|
+
throw new unexpected_call_error_1.default('Not supported "toggle" method');
|
|
107
|
+
}
|
|
108
108
|
_pick(token, _offset = 0) {
|
|
109
109
|
var _a, _b, _c, _d, _e, _f;
|
|
110
110
|
token = token.trim().split(/\s+/g)[0];
|
|
@@ -134,4 +134,4 @@ class MLDomTokenList extends Array {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
exports.MLDomTokenList = MLDomTokenList;
|
|
137
|
-
|
|
137
|
+
_MLDomTokenList_origin = new WeakMap(), _MLDomTokenList_ownerAttrs = new WeakMap(), _MLDomTokenList_set = new WeakMap();
|