@markuplint/ml-core 2.3.0 → 3.0.0-alpha.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.
Files changed (98) hide show
  1. package/lib/configs.d.ts +1 -1
  2. package/lib/configs.js +29 -9
  3. package/lib/index.d.ts +8 -8
  4. package/lib/index.js +18 -10
  5. package/lib/ml-core.d.ts +3 -3
  6. package/lib/ml-core.js +41 -42
  7. package/lib/ml-dom/document.d.ts +79 -70
  8. package/lib/ml-dom/helper/accname.d.ts +2 -2
  9. package/lib/ml-dom/helper/accname.js +2 -3
  10. package/lib/ml-dom/helper/create-node.d.ts +3 -4
  11. package/lib/ml-dom/helper/create-node.js +11 -15
  12. package/lib/ml-dom/helper/debug.d.ts +2 -2
  13. package/lib/ml-dom/helper/debug.js +35 -21
  14. package/lib/ml-dom/helper/getIndent.d.ts +5 -5
  15. package/lib/ml-dom/helper/getIndent.js +14 -14
  16. package/lib/ml-dom/helper/mapped-nodes.d.ts +51 -3
  17. package/lib/ml-dom/helper/match-selector.d.ts +10 -6
  18. package/lib/ml-dom/helper/node-store.d.ts +6 -3
  19. package/lib/ml-dom/helper/selector.d.ts +4 -4
  20. package/lib/ml-dom/helper/walkers.d.ts +5 -4
  21. package/lib/ml-dom/helper/walkers.js +39 -3
  22. package/lib/ml-dom/index.d.ts +8 -3
  23. package/lib/ml-dom/index.js +3 -15
  24. package/lib/ml-dom/manipulations/child-node-methods.d.ts +33 -0
  25. package/lib/ml-dom/manipulations/child-node-methods.js +73 -0
  26. package/lib/ml-dom/manipulations/get-children.d.ts +4 -0
  27. package/lib/ml-dom/manipulations/get-children.js +10 -0
  28. package/lib/ml-dom/node/attr.d.ts +98 -0
  29. package/lib/ml-dom/node/attr.js +157 -0
  30. package/lib/ml-dom/node/block.d.ts +38 -0
  31. package/lib/ml-dom/node/block.js +53 -0
  32. package/lib/ml-dom/node/character-data.d.ts +57 -0
  33. package/lib/ml-dom/node/character-data.js +87 -0
  34. package/lib/ml-dom/node/child-node.d.ts +9 -0
  35. package/lib/ml-dom/node/child-node.js +10 -0
  36. package/lib/ml-dom/node/comment.d.ts +17 -0
  37. package/lib/ml-dom/node/comment.js +24 -0
  38. package/lib/ml-dom/node/document-fragment.d.ts +24 -0
  39. package/lib/ml-dom/node/document-fragment.js +33 -0
  40. package/lib/ml-dom/node/document-type.d.ts +38 -0
  41. package/lib/ml-dom/node/document-type.js +52 -0
  42. package/lib/ml-dom/node/document.d.ts +1554 -0
  43. package/lib/ml-dom/node/document.js +2117 -0
  44. package/lib/ml-dom/node/dom-token-list.d.ts +33 -0
  45. package/lib/ml-dom/node/dom-token-list.js +137 -0
  46. package/lib/ml-dom/node/element.d.ts +1825 -0
  47. package/lib/ml-dom/node/element.js +2460 -0
  48. package/lib/ml-dom/node/named-node-map.d.ts +42 -0
  49. package/lib/ml-dom/node/named-node-map.js +64 -0
  50. package/lib/ml-dom/node/node-list.d.ts +6 -0
  51. package/lib/ml-dom/node/node-list.js +39 -0
  52. package/lib/ml-dom/node/node-store.d.ts +14 -0
  53. package/lib/ml-dom/node/node-store.js +32 -0
  54. package/lib/ml-dom/node/node.d.ts +475 -0
  55. package/lib/ml-dom/node/node.js +666 -0
  56. package/lib/ml-dom/node/parent-node.d.ts +66 -0
  57. package/lib/ml-dom/node/parent-node.js +131 -0
  58. package/lib/ml-dom/node/rule-mapper.d.ts +17 -0
  59. package/lib/ml-dom/node/rule-mapper.js +49 -0
  60. package/lib/ml-dom/node/text.d.ts +51 -0
  61. package/lib/ml-dom/node/text.js +76 -0
  62. package/lib/ml-dom/node/types.d.ts +25 -0
  63. package/lib/ml-dom/node/types.js +2 -0
  64. package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -0
  65. package/lib/ml-dom/node/unexpected-call-error.js +5 -0
  66. package/lib/ml-dom/rule-mapper.d.ts +7 -7
  67. package/lib/ml-dom/token/token.d.ts +47 -0
  68. package/lib/ml-dom/token/token.js +89 -0
  69. package/lib/ml-dom/tokens/abstract-element.d.ts +47 -42
  70. package/lib/ml-dom/tokens/attribute.d.ts +38 -38
  71. package/lib/ml-dom/tokens/comment.d.ts +7 -4
  72. package/lib/ml-dom/tokens/doctype.d.ts +12 -9
  73. package/lib/ml-dom/tokens/element-close-tag.d.ts +20 -17
  74. package/lib/ml-dom/tokens/element.d.ts +18 -15
  75. package/lib/ml-dom/tokens/node.d.ts +38 -31
  76. package/lib/ml-dom/tokens/omitted-element.d.ts +7 -4
  77. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +20 -20
  78. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +8 -5
  79. package/lib/ml-dom/tokens/text.d.ts +13 -9
  80. package/lib/ml-dom/tokens/token.d.ts +13 -13
  81. package/lib/ml-dom/types.d.ts +35 -13
  82. package/lib/ml-rule/ml-rule-context.d.ts +13 -10
  83. package/lib/ml-rule/ml-rule-context.js +12 -6
  84. package/lib/ml-rule/ml-rule.d.ts +8 -8
  85. package/lib/ml-rule/ml-rule.js +62 -62
  86. package/lib/ml-rule/types.d.ts +11 -1
  87. package/lib/ruleset/index.d.ts +2 -2
  88. package/lib/selector/is-pure-html-element.d.ts +1 -0
  89. package/lib/selector/is-pure-html-element.js +7 -0
  90. package/lib/selector/match-selector.d.ts +14 -0
  91. package/lib/selector/match-selector.js +230 -0
  92. package/lib/selector/selector.d.ts +9 -0
  93. package/lib/selector/selector.js +561 -0
  94. package/lib/test/index.d.ts +2 -1
  95. package/lib/test/index.js +7 -2
  96. package/package.json +10 -9
  97. package/tsconfig.tsbuildinfo +1 -1
  98. package/markuplint-recommended.json +0 -196
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var _MLAttr_localName, _MLAttr_namespaceURI, _MLAttr_potentialName, _MLAttr_potentialValue;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.MLAttr = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const ml_spec_1 = require("@markuplint/ml-spec");
7
+ const token_1 = require("../token/token");
8
+ const dom_token_list_1 = require("./dom-token-list");
9
+ const node_1 = require("./node");
10
+ const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
11
+ class MLAttr extends node_1.MLNode {
12
+ constructor(astToken, ownElement) {
13
+ var _a;
14
+ super(astToken, ownElement.ownerMLDocument);
15
+ _MLAttr_localName.set(this, void 0);
16
+ _MLAttr_namespaceURI.set(this, void 0);
17
+ _MLAttr_potentialName.set(this, void 0);
18
+ _MLAttr_potentialValue.set(this, void 0);
19
+ this.endQuote = null;
20
+ this.equal = null;
21
+ this.nameNode = null;
22
+ this.spacesAfterEqual = null;
23
+ this.spacesBeforeEqual = null;
24
+ this.spacesBeforeName = null;
25
+ this.startQuote = null;
26
+ this.valueNode = null;
27
+ /**
28
+ * Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
29
+ *
30
+ * @default "string"
31
+ * @implements `@markuplint/ml-core` API: `MLAttr`
32
+ */
33
+ this.valueType = 'string';
34
+ if (this._astToken.type === 'html-attr') {
35
+ this.spacesBeforeName = new token_1.MLToken(this._astToken.spacesBeforeName);
36
+ this.nameNode = new token_1.MLToken(this._astToken.name);
37
+ this.spacesBeforeEqual = new token_1.MLToken(this._astToken.spacesBeforeEqual);
38
+ this.equal = new token_1.MLToken(this._astToken.equal);
39
+ this.spacesAfterEqual = new token_1.MLToken(this._astToken.spacesAfterEqual);
40
+ this.startQuote = new token_1.MLToken(this._astToken.startQuote);
41
+ this.valueNode = new token_1.MLToken(this._astToken.value);
42
+ this.endQuote = new token_1.MLToken(this._astToken.endQuote);
43
+ this.isDynamicValue = this._astToken.isDynamicValue;
44
+ this.isDirective = this._astToken.isDirective;
45
+ this.candidate = this._astToken.candidate;
46
+ tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName || ((_a = this.nameNode) === null || _a === void 0 ? void 0 : _a.raw) || '', "f");
47
+ tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.value.raw || '', "f");
48
+ }
49
+ else {
50
+ this.valueType = this._astToken.valueType;
51
+ this.isDuplicatable = this._astToken.isDuplicatable;
52
+ tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName, "f");
53
+ tslib_1.__classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.potentialValue, "f");
54
+ }
55
+ const ns = (0, ml_spec_1.resolveNamespace)(tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialName, "f"), ownElement.namespaceURI);
56
+ tslib_1.__classPrivateFieldSet(this, _MLAttr_localName, ns.localName, "f");
57
+ tslib_1.__classPrivateFieldSet(this, _MLAttr_namespaceURI, ns.namespaceURI, "f");
58
+ this.ownerElement = ownElement;
59
+ this.isDuplicatable = this._astToken.isDuplicatable;
60
+ }
61
+ /**
62
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
63
+ *
64
+ * @unsupported
65
+ * @implements DOM API: `Attr`
66
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
67
+ */
68
+ get localName() {
69
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_localName, "f");
70
+ }
71
+ /**
72
+ *
73
+ * @implements DOM API: `Attr`
74
+ * @see https://dom.spec.whatwg.org/#dom-attr-name
75
+ */
76
+ get name() {
77
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialName, "f");
78
+ }
79
+ /**
80
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
81
+ *
82
+ * @unsupported
83
+ * @implements DOM API: `Attr`
84
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
85
+ */
86
+ get namespaceURI() {
87
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_namespaceURI, "f");
88
+ }
89
+ /**
90
+ * Returns a string appropriate for the type of node as `Attr`
91
+ *
92
+ * @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
93
+ */
94
+ get nodeName() {
95
+ return this.name;
96
+ }
97
+ /**
98
+ * Returns a number appropriate for the type of `Attr`
99
+ */
100
+ get nodeType() {
101
+ return this.ATTRIBUTE_NODE;
102
+ }
103
+ get nodeValue() {
104
+ return this.value;
105
+ }
106
+ /**
107
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
108
+ *
109
+ * @unsupported
110
+ * @implements DOM API: `Attr`
111
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
112
+ */
113
+ get prefix() {
114
+ throw new unexpected_call_error_1.default('Not supported "prefix" property');
115
+ }
116
+ /**
117
+ * @implements `@markuplint/ml-core` API: `MLAttr`
118
+ */
119
+ get rule() {
120
+ return this.ownerElement.rule;
121
+ }
122
+ /**
123
+ * @implements DOM API: `Attr`
124
+ * @see https://dom.spec.whatwg.org/#dom-attr-specified
125
+ */
126
+ get specified() {
127
+ return true;
128
+ }
129
+ /**
130
+ * @implements DOM API: `Attr`
131
+ * @see https://dom.spec.whatwg.org/#dom-attr-value
132
+ */
133
+ get value() {
134
+ return tslib_1.__classPrivateFieldGet(this, _MLAttr_potentialValue, "f");
135
+ }
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
+ /**
143
+ * @implements `@markuplint/ml-core` API: `MLAttr`
144
+ */
145
+ toNormalizeString() {
146
+ if (this.nameNode && this.equal && this.startQuote && this.valueNode && this.endQuote) {
147
+ return (this.nameNode.originRaw +
148
+ this.equal.originRaw +
149
+ this.startQuote.originRaw +
150
+ this.valueNode.originRaw +
151
+ this.endQuote.originRaw);
152
+ }
153
+ return this.raw;
154
+ }
155
+ }
156
+ exports.MLAttr = MLAttr;
157
+ _MLAttr_localName = new WeakMap(), _MLAttr_namespaceURI = new WeakMap(), _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
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MLComment = void 0;
4
+ const character_data_1 = require("./character-data");
5
+ class MLComment extends character_data_1.MLCharacterData {
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() {
12
+ return '#comment';
13
+ }
14
+ /**
15
+ * Returns a number appropriate for the type of `Comment`
16
+ */
17
+ get nodeType() {
18
+ return this.COMMENT_NODE;
19
+ }
20
+ get textContent() {
21
+ return this.nodeValue;
22
+ }
23
+ }
24
+ exports.MLComment = MLComment;
@@ -0,0 +1,24 @@
1
+ import type { DocumentFragmentNodeType } from './types';
2
+ import type { MLASTAbstructNode } from '@markuplint/ml-ast';
3
+ import type { RuleConfigValue } from '@markuplint/ml-config';
4
+ import { MLParentNode } from './parent-node';
5
+ export declare class MLDocumentFragment<T extends RuleConfigValue, O = null> extends MLParentNode<T, O, MLASTAbstructNode> implements DocumentFragment {
6
+ /**
7
+ * Returns a string appropriate for the type of node as `DocumentFragment`
8
+ *
9
+ * @see https://dom.spec.whatwg.org/#ref-for-documentfragment%E2%91%A0%E2%91%A6
10
+ */
11
+ get nodeName(): "#document-fragment";
12
+ /**
13
+ * Returns a number appropriate for the type of `DocumentFragment`
14
+ */
15
+ get nodeType(): DocumentFragmentNodeType;
16
+ /**
17
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
18
+ *
19
+ * @deprecated
20
+ * @unsupported
21
+ * @implements DOM API: `DocumentFragment`
22
+ */
23
+ getElementById(elementId: string): HTMLElement | null;
24
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MLDocumentFragment = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const parent_node_1 = require("./parent-node");
6
+ const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
7
+ class MLDocumentFragment extends parent_node_1.MLParentNode {
8
+ /**
9
+ * Returns a string appropriate for the type of node as `DocumentFragment`
10
+ *
11
+ * @see https://dom.spec.whatwg.org/#ref-for-documentfragment%E2%91%A0%E2%91%A6
12
+ */
13
+ get nodeName() {
14
+ return '#document-fragment';
15
+ }
16
+ /**
17
+ * Returns a number appropriate for the type of `DocumentFragment`
18
+ */
19
+ get nodeType() {
20
+ return this.DOCUMENT_FRAGMENT_NODE;
21
+ }
22
+ /**
23
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
24
+ *
25
+ * @deprecated
26
+ * @unsupported
27
+ * @implements DOM API: `DocumentFragment`
28
+ */
29
+ getElementById(elementId) {
30
+ throw new unexpected_call_error_1.default('Not supported "getElementById" method');
31
+ }
32
+ }
33
+ exports.MLDocumentFragment = MLDocumentFragment;
@@ -0,0 +1,38 @@
1
+ import type { MLDocument } from './document';
2
+ import type { MLElement } from './element';
3
+ import type { DocumentTypeNodeType } from './types';
4
+ import type { MLASTDoctype } from '@markuplint/ml-ast';
5
+ import type { RuleConfigValue } from '@markuplint/ml-config';
6
+ import { MLNode } from './node';
7
+ export declare class MLDocumentType<T extends RuleConfigValue, O = null> extends MLNode<T, O, MLASTDoctype> implements DocumentType {
8
+ readonly name: string;
9
+ readonly publicId: string;
10
+ readonly systemId: string;
11
+ /**
12
+ * Returns a string appropriate for the type of node as `DocumentType`
13
+ *
14
+ * @see https://dom.spec.whatwg.org/#ref-for-documenttype%E2%91%A0%E2%93%AA
15
+ */
16
+ get nodeName(): string;
17
+ /**
18
+ * Returns a number appropriate for the type of `DocumentType`
19
+ */
20
+ get nodeType(): DocumentTypeNodeType;
21
+ constructor(astNode: MLASTDoctype, document: MLDocument<T, O>);
22
+ /**
23
+ * @implements DOM API: `CharacterData`
24
+ */
25
+ after(...nodes: (string | MLElement<any, any>)[]): void;
26
+ /**
27
+ * @implements DOM API: `CharacterData`
28
+ */
29
+ before(...nodes: (string | MLElement<any, any>)[]): void;
30
+ /**
31
+ * @implements DOM API: `CharacterData`
32
+ */
33
+ remove(): void;
34
+ /**
35
+ * @implements DOM API: `CharacterData`
36
+ */
37
+ replaceWith(...nodes: (string | MLElement<any, any>)[]): void;
38
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MLDocumentType = void 0;
4
+ const child_node_methods_1 = require("../manipulations/child-node-methods");
5
+ const node_1 = require("./node");
6
+ class MLDocumentType extends node_1.MLNode {
7
+ constructor(astNode, document) {
8
+ super(astNode, document);
9
+ this.name = astNode.name;
10
+ this.publicId = astNode.publicId;
11
+ this.systemId = astNode.systemId;
12
+ }
13
+ /**
14
+ * Returns a string appropriate for the type of node as `DocumentType`
15
+ *
16
+ * @see https://dom.spec.whatwg.org/#ref-for-documenttype%E2%91%A0%E2%93%AA
17
+ */
18
+ get nodeName() {
19
+ return this.name;
20
+ }
21
+ /**
22
+ * Returns a number appropriate for the type of `DocumentType`
23
+ */
24
+ get nodeType() {
25
+ return this.DOCUMENT_TYPE_NODE;
26
+ }
27
+ /**
28
+ * @implements DOM API: `CharacterData`
29
+ */
30
+ after(...nodes) {
31
+ (0, child_node_methods_1.after)(this, ...nodes);
32
+ }
33
+ /**
34
+ * @implements DOM API: `CharacterData`
35
+ */
36
+ before(...nodes) {
37
+ (0, child_node_methods_1.before)(this, ...nodes);
38
+ }
39
+ /**
40
+ * @implements DOM API: `CharacterData`
41
+ */
42
+ remove() {
43
+ (0, child_node_methods_1.remove)(this);
44
+ }
45
+ /**
46
+ * @implements DOM API: `CharacterData`
47
+ */
48
+ replaceWith(...nodes) {
49
+ (0, child_node_methods_1.replaceWith)(this, ...nodes);
50
+ }
51
+ }
52
+ exports.MLDocumentType = MLDocumentType;