@markuplint/ml-core 2.3.2 → 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 (57) 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 +3 -3
  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/node/attr.d.ts +5 -0
  25. package/lib/ml-dom/node/attr.js +17 -4
  26. package/lib/ml-dom/node/document.js +1 -1
  27. package/lib/ml-dom/node/dom-token-list.d.ts +20 -2
  28. package/lib/ml-dom/node/dom-token-list.js +85 -9
  29. package/lib/ml-dom/node/element.d.ts +4 -11
  30. package/lib/ml-dom/node/element.js +13 -36
  31. package/lib/ml-dom/node/node.js +2 -8
  32. package/lib/ml-dom/rule-mapper.d.ts +7 -7
  33. package/lib/ml-dom/tokens/abstract-element.d.ts +47 -42
  34. package/lib/ml-dom/tokens/attribute.d.ts +38 -38
  35. package/lib/ml-dom/tokens/comment.d.ts +7 -4
  36. package/lib/ml-dom/tokens/doctype.d.ts +12 -9
  37. package/lib/ml-dom/tokens/element-close-tag.d.ts +20 -17
  38. package/lib/ml-dom/tokens/element.d.ts +18 -15
  39. package/lib/ml-dom/tokens/node.d.ts +38 -31
  40. package/lib/ml-dom/tokens/omitted-element.d.ts +7 -4
  41. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +20 -20
  42. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +8 -5
  43. package/lib/ml-dom/tokens/text.d.ts +13 -9
  44. package/lib/ml-dom/tokens/token.d.ts +13 -13
  45. package/lib/ml-dom/types.d.ts +35 -13
  46. package/lib/ml-rule/ml-rule-context.d.ts +13 -10
  47. package/lib/ml-rule/ml-rule-context.js +12 -6
  48. package/lib/ml-rule/ml-rule.d.ts +8 -8
  49. package/lib/ml-rule/ml-rule.js +62 -62
  50. package/lib/ml-rule/types.d.ts +11 -1
  51. package/lib/ruleset/index.d.ts +2 -2
  52. package/lib/selector/match-selector.d.ts +5 -5
  53. package/lib/test/index.d.ts +2 -1
  54. package/lib/test/index.js +7 -2
  55. package/package.json +10 -9
  56. package/tsconfig.tsbuildinfo +1 -1
  57. package/markuplint-recommended.json +0 -196
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var _MLElement_attributes, _MLElement_fixedNodeName, _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache, _MLElement_normalizedAttrs, _MLElement_normalizedString, _MLElement_tagOpenChar;
2
+ var _MLElement_attributes, _MLElement_fixedNodeName, _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache, _MLElement_normalizedAttrs, _MLElement_normalizedString, _MLElement_localName, _MLElement_tagOpenChar;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.MLElement = void 0;
5
5
  const tslib_1 = require("tslib");
@@ -24,13 +24,16 @@ class MLElement extends parent_node_1.MLParentNode {
24
24
  _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache.set(this, null);
25
25
  _MLElement_normalizedAttrs.set(this, null);
26
26
  _MLElement_normalizedString.set(this, null);
27
+ _MLElement_localName.set(this, void 0);
27
28
  _MLElement_tagOpenChar.set(this, void 0);
28
29
  tslib_1.__classPrivateFieldSet(this, _MLElement_attributes, astNode.attributes.map(attr => new attr_1.MLAttr(attr, this)), "f");
29
30
  this.hasSpreadAttr = astNode.hasSpreadAttr;
30
31
  this.selfClosingSolidus = astNode.selfClosingSolidus ? new token_1.MLToken(astNode.selfClosingSolidus) : null;
31
32
  this.endSpace = astNode.endSpace ? new token_1.MLToken(astNode.endSpace) : null;
32
33
  this.closeTag = astNode.pearNode ? new token_1.MLToken(astNode.pearNode) : null;
33
- this.namespaceURI = astNode.namespace || HTML_NAMESPACE;
34
+ const ns = (0, ml_spec_1.resolveNamespace)(astNode.nodeName, astNode.namespace);
35
+ this.namespaceURI = ns.namespaceURI;
36
+ tslib_1.__classPrivateFieldSet(this, _MLElement_localName, ns.localName, "f");
34
37
  this.isForeignElement = this.namespaceURI !== HTML_NAMESPACE;
35
38
  this.isCustomElement = astNode.isCustomElement;
36
39
  tslib_1.__classPrivateFieldSet(this, _MLElement_fixedNodeName, astNode.nodeName, "f");
@@ -476,20 +479,16 @@ class MLElement extends parent_node_1.MLParentNode {
476
479
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-classlist%E2%91%A0
477
480
  */
478
481
  get classList() {
479
- return (0, dom_token_list_1.toDOMTokenList)(this.className);
482
+ const classAttrs = this.getAttributeToken('class');
483
+ const value = classAttrs.map(c => c.value).join(' ');
484
+ return new dom_token_list_1.MLDomTokenList(value, classAttrs);
480
485
  }
481
486
  /**
482
487
  * @implements DOM API: `Element`
483
488
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-classname%E2%91%A0
484
489
  */
485
490
  get className() {
486
- const classNames = [];
487
- for (const classNameToken of this.getAttributeToken('class')) {
488
- if (classNames.length === 0 || classNameToken.isDuplicatable) {
489
- classNames.push(classNameToken.value);
490
- }
491
- }
492
- return classNames.join(' ');
491
+ return this.classList.value;
493
492
  }
494
493
  /**
495
494
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -671,22 +670,9 @@ class MLElement extends parent_node_1.MLParentNode {
671
670
  */
672
671
  get localName() {
673
672
  if (this.isForeignElement || this.isCustomElement) {
674
- return this._astToken.nodeName;
675
- }
676
- return this._astToken.nodeName.toLowerCase();
677
- }
678
- /**
679
- * @implements `@markuplint/ml-core` API: `MLElement`
680
- */
681
- get nameWithNS() {
682
- if (/[a-z]:[a-z]/i.test(this.localName)) {
683
- return this.localName;
684
- }
685
- const ns = (0, ml_spec_1.getNS)(this.namespaceURI || '');
686
- if (ns === 'html') {
687
- return this.localName;
673
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f");
688
674
  }
689
- return `${ns}:${this.localName}`;
675
+ return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f").toLowerCase();
690
676
  }
691
677
  /**
692
678
  * The element immediately following the specified one in its parent's children list.
@@ -725,15 +711,6 @@ class MLElement extends parent_node_1.MLParentNode {
725
711
  get nonce() {
726
712
  throw new unexpected_call_error_1.default('Not supported "nonce" property');
727
713
  }
728
- /**
729
- * @implements `@markuplint/ml-core` API: `MLElement`
730
- */
731
- get ns() {
732
- if (/[a-z]:[a-z]/i.test(this.localName)) {
733
- return this.localName.split(':')[0];
734
- }
735
- return (0, ml_spec_1.getNS)(this.namespaceURI || '');
736
- }
737
714
  /**
738
715
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
739
716
  *
@@ -2266,7 +2243,7 @@ class MLElement extends parent_node_1.MLParentNode {
2266
2243
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
2267
2244
  */
2268
2245
  matches(selector) {
2269
- return !!(0, selector_1.createSelector)(selector).match(this);
2246
+ return !!(0, selector_1.createSelector)(selector, this.ownerMLDocument.specs).match(this);
2270
2247
  }
2271
2248
  /**
2272
2249
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -2480,4 +2457,4 @@ class MLElement extends parent_node_1.MLParentNode {
2480
2457
  }
2481
2458
  }
2482
2459
  exports.MLElement = MLElement;
2483
- _MLElement_attributes = new WeakMap(), _MLElement_fixedNodeName = new WeakMap(), _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache = new WeakMap(), _MLElement_normalizedAttrs = new WeakMap(), _MLElement_normalizedString = new WeakMap(), _MLElement_tagOpenChar = new WeakMap();
2460
+ _MLElement_attributes = new WeakMap(), _MLElement_fixedNodeName = new WeakMap(), _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache = new WeakMap(), _MLElement_normalizedAttrs = new WeakMap(), _MLElement_normalizedString = new WeakMap(), _MLElement_localName = new WeakMap(), _MLElement_tagOpenChar = new WeakMap();
@@ -536,14 +536,8 @@ class MLNode extends token_1.MLToken {
536
536
  if (options) {
537
537
  throw new unexpected_call_error_1.default('Not supported options');
538
538
  }
539
- let parent = this.parentNode;
540
- while (parent) {
541
- if (!parent.parentNode) {
542
- return parent;
543
- }
544
- parent = parent.parentNode;
545
- }
546
- return parent || this;
539
+ // The original DOM API returns a document fragment if the element is a fragment.
540
+ return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
547
541
  }
548
542
  /**
549
543
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -3,14 +3,14 @@ import type { AnonymousNode } from './types';
3
3
  import type { AnyRule } from '@markuplint/ml-config';
4
4
  declare type RuleType = 'rules' | 'nodeRules' | 'childNodeRules';
5
5
  declare type MappingLayer = {
6
- from: RuleType;
7
- specificity: Specificity;
8
- rule: AnyRule;
6
+ from: RuleType;
7
+ specificity: Specificity;
8
+ rule: AnyRule;
9
9
  };
10
10
  export declare class RuleMapper<N extends AnonymousNode<any, any> = AnonymousNode<any, any>> {
11
- #private;
12
- constructor(nodeList: ReadonlyArray<N>);
13
- set(node: N, ruleName: string, rule: MappingLayer): void;
14
- apply(): void;
11
+ #private;
12
+ constructor(nodeList: ReadonlyArray<N>);
13
+ set(node: N, ruleName: string, rule: MappingLayer): void;
14
+ apply(): void;
15
15
  }
16
16
  export {};
@@ -3,47 +3,52 @@ import type { MLDOMAttribute, MLDOMElement, MLDOMOmittedElement, MLDOMText } fro
3
3
  import type MLDOMPreprocessorSpecificAttribute from './preprocessor-specific-attribute';
4
4
  import type { MLASTElement, MLASTOmittedElement } from '@markuplint/ml-ast';
5
5
  import type { RuleConfigValue } from '@markuplint/ml-config';
6
- import type { ContentModel } from '@markuplint/ml-spec';
6
+ import type { Category } from '@markuplint/ml-spec';
7
+
7
8
  import MLDOMNode from './node';
8
- export default abstract class MLDOMAbstractElement<T extends RuleConfigValue, O = null, E extends MLASTElement | MLASTOmittedElement = MLASTElement | MLASTOmittedElement> extends MLDOMNode<T, O, E> {
9
- #private;
10
- readonly nodeType = 1;
11
- readonly nodeName: string;
12
- readonly attributes: (MLDOMAttribute | MLDOMPreprocessorSpecificAttribute)[];
13
- readonly hasSpreadAttr: boolean;
14
- readonly namespaceURI: string;
15
- readonly isForeignElement: boolean;
16
- readonly ownModels: Set<ContentModel>;
17
- readonly childModels: Set<ContentModel>;
18
- readonly descendantModels: Set<ContentModel>;
19
- readonly isCustomElement: boolean;
20
- readonly isInFragmentDocument: boolean;
21
- constructor(astNode: E, document: Document<T, O>);
22
- get tagName(): string;
23
- get children(): (MLDOMElement<T, O> | MLDOMOmittedElement<T, O>)[];
24
- get nextElementSibling(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
25
- get previousElementSibling(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
26
- get ns(): string;
27
- get nameWithNS(): string;
28
- get classList(): string[];
29
- get id(): string;
30
- get fixedNodeName(): string;
31
- get textContent(): string;
32
- querySelectorAll(selector: string): (MLDOMElement<T, O> | MLDOMText<T, O>)[];
33
- closest(selector: string): MLDOMAbstractElement<T, O> | null;
34
- getAttributeToken(attrName: string): (MLDOMAttribute | MLDOMPreprocessorSpecificAttribute)[];
35
- getAttributeNode(attrName: string): MLDOMAttribute | MLDOMPreprocessorSpecificAttribute;
36
- getAttribute(attrName: string): string | null;
37
- hasAttribute(attrName: string): boolean;
38
- matches(selector: string): boolean;
39
- fixNodeName(name: string): void;
40
- getChildElementsAndTextNodeWithoutWhitespaces(): (MLDOMElement<T, O> | MLDOMText<T, O>)[];
41
- /**
42
- * This element has "Preprocessor Specific Block". In other words, Its children are potentially mutable.
43
- */
44
- hasMutableChildren(attr?: boolean): boolean;
45
- hasMutableAttributes(): boolean;
46
- isDescendantByUUIDList(uuidList: string[]): boolean;
47
- getAccessibleName(): string;
48
- toNormalizeString(): string;
9
+ export default abstract class MLDOMAbstractElement<
10
+ T extends RuleConfigValue,
11
+ O = null,
12
+ E extends MLASTElement | MLASTOmittedElement = MLASTElement | MLASTOmittedElement,
13
+ > extends MLDOMNode<T, O, E> {
14
+ #private;
15
+ readonly nodeType = 1;
16
+ readonly nodeName: string;
17
+ readonly attributes: (MLDOMAttribute | MLDOMPreprocessorSpecificAttribute)[];
18
+ readonly hasSpreadAttr: boolean;
19
+ readonly namespaceURI: string;
20
+ readonly isForeignElement: boolean;
21
+ readonly ownModels: Set<Category>;
22
+ readonly childModels: Set<Category>;
23
+ readonly descendantModels: Set<Category>;
24
+ readonly isCustomElement: boolean;
25
+ readonly isInFragmentDocument: boolean;
26
+ constructor(astNode: E, document: Document<T, O>);
27
+ get tagName(): string;
28
+ get children(): (MLDOMElement<T, O> | MLDOMOmittedElement<T, O>)[];
29
+ get nextElementSibling(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
30
+ get previousElementSibling(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
31
+ get ns(): string;
32
+ get nameWithNS(): string;
33
+ get classList(): string[];
34
+ get id(): string;
35
+ get fixedNodeName(): string;
36
+ get textContent(): string;
37
+ querySelectorAll(selector: string): (MLDOMElement<T, O> | MLDOMText<T, O>)[];
38
+ closest(selector: string): MLDOMAbstractElement<T, O> | null;
39
+ getAttributeToken(attrName: string): (MLDOMAttribute | MLDOMPreprocessorSpecificAttribute)[];
40
+ getAttributeNode(attrName: string): MLDOMAttribute | MLDOMPreprocessorSpecificAttribute;
41
+ getAttribute(attrName: string): string | null;
42
+ hasAttribute(attrName: string): boolean;
43
+ matches(selector: string): boolean;
44
+ fixNodeName(name: string): void;
45
+ getChildElementsAndTextNodeWithoutWhitespaces(): (MLDOMElement<T, O> | MLDOMText<T, O>)[];
46
+ /**
47
+ * This element has "Preprocessor Specific Block". In other words, Its children are potentially mutable.
48
+ */
49
+ hasMutableChildren(attr?: boolean): boolean;
50
+ hasMutableAttributes(): boolean;
51
+ isDescendantByUUIDList(uuidList: string[]): boolean;
52
+ getAccessibleName(): string;
53
+ toNormalizeString(): string;
49
54
  }
@@ -1,42 +1,42 @@
1
1
  import type { MLASTHTMLAttr, MLToken } from '@markuplint/ml-ast';
2
2
  import MLDOMToken from './token';
3
3
  export default class MLDOMAttribute extends MLDOMToken<MLASTHTMLAttr> {
4
- readonly nodeType = 2;
5
- readonly attrType = "html-attr";
6
- readonly name: MLDOMToken<MLToken>;
7
- readonly spacesBeforeName: MLDOMToken<MLToken>;
8
- readonly spacesBeforeEqual: MLDOMToken<MLToken>;
9
- readonly equal: MLDOMToken<MLToken>;
10
- readonly spacesAfterEqual: MLDOMToken<MLToken>;
11
- readonly startQuote: MLDOMToken<MLToken>;
12
- readonly valueNode: MLDOMToken<MLToken>;
13
- readonly endQuote: MLDOMToken<MLToken>;
14
- readonly isDynamicValue?: true;
15
- readonly isDirective?: true;
16
- readonly potentialName: string;
17
- readonly candidate?: string;
18
- readonly isDuplicatable: boolean;
19
- constructor(astToken: MLASTHTMLAttr);
20
- get raw(): string;
21
- get startOffset(): number;
22
- get endOffset(): number;
23
- get startLine(): number;
24
- get endLine(): number;
25
- get startCol(): number;
26
- get endCol(): number;
27
- get value(): string;
28
- getName(): {
29
- line: number;
30
- col: number;
31
- potential: string;
32
- raw: string;
33
- };
34
- getValue(): {
35
- line: number;
36
- col: number;
37
- potential: string;
38
- raw: string;
39
- };
40
- toString(withSpace?: boolean): string;
41
- toNormalizeString(): string;
4
+ readonly nodeType = 2;
5
+ readonly attrType = 'html-attr';
6
+ readonly name: MLDOMToken<MLToken>;
7
+ readonly spacesBeforeName: MLDOMToken<MLToken>;
8
+ readonly spacesBeforeEqual: MLDOMToken<MLToken>;
9
+ readonly equal: MLDOMToken<MLToken>;
10
+ readonly spacesAfterEqual: MLDOMToken<MLToken>;
11
+ readonly startQuote: MLDOMToken<MLToken>;
12
+ readonly valueNode: MLDOMToken<MLToken>;
13
+ readonly endQuote: MLDOMToken<MLToken>;
14
+ readonly isDynamicValue?: true;
15
+ readonly isDirective?: true;
16
+ readonly potentialName: string;
17
+ readonly candidate?: string;
18
+ readonly isDuplicatable: boolean;
19
+ constructor(astToken: MLASTHTMLAttr);
20
+ get raw(): string;
21
+ get startOffset(): number;
22
+ get endOffset(): number;
23
+ get startLine(): number;
24
+ get endLine(): number;
25
+ get startCol(): number;
26
+ get endCol(): number;
27
+ get value(): string;
28
+ getName(): {
29
+ line: number;
30
+ col: number;
31
+ potential: string;
32
+ raw: string;
33
+ };
34
+ getValue(): {
35
+ line: number;
36
+ col: number;
37
+ potential: string;
38
+ raw: string;
39
+ };
40
+ toString(withSpace?: boolean): string;
41
+ toNormalizeString(): string;
42
42
  }
@@ -2,8 +2,11 @@ import type { IMLDOMComment } from '../types';
2
2
  import type { MLASTComment } from '@markuplint/ml-ast';
3
3
  import type { RuleConfigValue } from '@markuplint/ml-config';
4
4
  import MLDOMNode from './node';
5
- export default class MLDOMComment<T extends RuleConfigValue, O = null> extends MLDOMNode<T, O, MLASTComment> implements IMLDOMComment {
6
- readonly nodeType = 8;
7
- readonly type = "Comment";
8
- get textContent(): string;
5
+ export default class MLDOMComment<T extends RuleConfigValue, O = null>
6
+ extends MLDOMNode<T, O, MLASTComment>
7
+ implements IMLDOMComment
8
+ {
9
+ readonly nodeType = 8;
10
+ readonly type = 'Comment';
11
+ get textContent(): string;
9
12
  }
@@ -3,13 +3,16 @@ import type { IMLDOMDoctype } from '../types';
3
3
  import type { MLASTDoctype, MLASTNode } from '@markuplint/ml-ast';
4
4
  import type { RuleConfigValue } from '@markuplint/ml-config';
5
5
  import MLDOMNode from './node';
6
- export default class MLDOMDoctype<T extends RuleConfigValue, O = null> extends MLDOMNode<T, O, MLASTNode> implements IMLDOMDoctype {
7
- #private;
8
- readonly nodeType = 10;
9
- readonly type = "Doctype";
10
- constructor(astNode: MLASTDoctype, document: Document<T, O>);
11
- get name(): string;
12
- get publicId(): string;
13
- get systemId(): string;
14
- get textContent(): null;
6
+ export default class MLDOMDoctype<T extends RuleConfigValue, O = null>
7
+ extends MLDOMNode<T, O, MLASTNode>
8
+ implements IMLDOMDoctype
9
+ {
10
+ #private;
11
+ readonly nodeType = 10;
12
+ readonly type = 'Doctype';
13
+ constructor(astNode: MLASTDoctype, document: Document<T, O>);
14
+ get name(): string;
15
+ get publicId(): string;
16
+ get systemId(): string;
17
+ get textContent(): null;
15
18
  }
@@ -4,21 +4,24 @@ import type { MLDOMElement } from './';
4
4
  import type { MLASTElementCloseTag } from '@markuplint/ml-ast';
5
5
  import type { RuleConfigValue } from '@markuplint/ml-config';
6
6
  import MLDOMNode from './node';
7
- export default class MLDOMElementCloseTag<T extends RuleConfigValue, O = null> extends MLDOMNode<T, O, MLASTElementCloseTag> implements IMLDOMElementCloseTag {
8
- #private;
9
- readonly nodeType = 1;
10
- readonly type = "ElementCloseTag";
11
- readonly nodeName: string;
12
- readonly startTag: MLDOMElement<T, O>;
13
- readonly isForeignElement: boolean;
14
- readonly isCustomElement: boolean;
15
- constructor(astNode: MLASTElementCloseTag, document: Document<T, O>, startTag: MLDOMElement<T, O>);
16
- get raw(): string;
17
- get rule(): import("@markuplint/ml-config").RuleInfo<T, O>;
18
- fixNodeName(name: string): void;
19
- getNameLocation(): {
20
- offset: number;
21
- line: number;
22
- col: number;
23
- };
7
+ export default class MLDOMElementCloseTag<T extends RuleConfigValue, O = null>
8
+ extends MLDOMNode<T, O, MLASTElementCloseTag>
9
+ implements IMLDOMElementCloseTag
10
+ {
11
+ #private;
12
+ readonly nodeType = 1;
13
+ readonly type = 'ElementCloseTag';
14
+ readonly nodeName: string;
15
+ readonly startTag: MLDOMElement<T, O>;
16
+ readonly isForeignElement: boolean;
17
+ readonly isCustomElement: boolean;
18
+ constructor(astNode: MLASTElementCloseTag, document: Document<T, O>, startTag: MLDOMElement<T, O>);
19
+ get raw(): string;
20
+ get rule(): import('@markuplint/ml-config').RuleInfo<T, O>;
21
+ fixNodeName(name: string): void;
22
+ getNameLocation(): {
23
+ offset: number;
24
+ line: number;
25
+ col: number;
26
+ };
24
27
  }
@@ -5,19 +5,22 @@ import type { MLASTElement, MLToken } from '@markuplint/ml-ast';
5
5
  import type { RuleConfigValue } from '@markuplint/ml-config';
6
6
  import MLDOMAbstractElement from './abstract-element';
7
7
  import MLDOMToken from './token';
8
- export default class MLDOMElement<T extends RuleConfigValue, O = null> extends MLDOMAbstractElement<T, O, MLASTElement> implements IMLDOMElement {
9
- #private;
10
- readonly type = "Element";
11
- readonly hasSpreadAttr: boolean;
12
- readonly closeTag: MLDOMElementCloseTag<T, O> | null;
13
- readonly selfClosingSolidus: MLDOMToken<MLToken> | null;
14
- readonly endSpace: MLDOMToken<MLToken> | null;
15
- constructor(astNode: MLASTElement, document: Document<T, O>);
16
- get raw(): string;
17
- querySelectorAll(selector: string): (MLDOMElement<T, O> | MLDOMText<T, O>)[];
18
- getNameLocation(): {
19
- offset: number;
20
- line: number;
21
- col: number;
22
- };
8
+ export default class MLDOMElement<T extends RuleConfigValue, O = null>
9
+ extends MLDOMAbstractElement<T, O, MLASTElement>
10
+ implements IMLDOMElement
11
+ {
12
+ #private;
13
+ readonly type = 'Element';
14
+ readonly hasSpreadAttr: boolean;
15
+ readonly closeTag: MLDOMElementCloseTag<T, O> | null;
16
+ readonly selfClosingSolidus: MLDOMToken<MLToken> | null;
17
+ readonly endSpace: MLDOMToken<MLToken> | null;
18
+ constructor(astNode: MLASTElement, document: Document<T, O>);
19
+ get raw(): string;
20
+ querySelectorAll(selector: string): (MLDOMElement<T, O> | MLDOMText<T, O>)[];
21
+ getNameLocation(): {
22
+ offset: number;
23
+ line: number;
24
+ col: number;
25
+ };
23
26
  }
@@ -5,35 +5,42 @@ import type { MLDOMElement, MLDOMOmittedElement, MLDOMPreprocessorSpecificBlock
5
5
  import type { MLASTAbstructNode } from '@markuplint/ml-ast';
6
6
  import type { AnyRule, RuleConfigValue } from '@markuplint/ml-config';
7
7
  import MLDOMToken from './token';
8
- export default abstract class MLDOMNode<T extends RuleConfigValue, O = null, A extends MLASTAbstructNode = MLASTAbstructNode> extends MLDOMToken<A> implements IMLDOMNode {
9
- #private;
10
- readonly ELEMENT_NODE = 1;
11
- readonly ATTRIBUTE_NODE = 2;
12
- readonly TEXT_NODE = 3;
13
- readonly CDATA_SECTION_NODE = 4;
14
- readonly ENTITY_REFERENCE_NODE = 5;
15
- readonly ENTITY_NODE = 6;
16
- readonly PROCESSING_INSTRUCTION_NODE = 7;
17
- readonly COMMENT_NODE = 8;
18
- readonly DOCUMENT_NODE = 9;
19
- readonly DOCUMENT_TYPE_NODE = 10;
20
- readonly DOCUMENT_FRAGMENT_NODE = 11;
21
- readonly NOTATION_NODE = 12;
22
- readonly ownerDocument: Document<T, O>;
23
- readonly type: NodeType;
24
- readonly rules: Record<string, AnyRule>;
25
- protected _astToken: A;
26
- constructor(astNode: A, document: Document<T, O>);
27
- get childNodes(): AnonymousNode<T, O>[];
28
- get parentNode(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
29
- get prevNode(): AnonymousNode<T, O> | null;
30
- get nextNode(): AnonymousNode<T, O> | null;
31
- get syntaxicalParentNode(): MLDOMElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
32
- get prevToken(): AnonymousNode<T, O> | null;
33
- get nodeStore(): import("../helper").NodeStore;
34
- get rule(): RuleInfo<T, O>;
35
- get textContent(): string | null;
36
- getParentElement(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
37
- is(type: NodeType): boolean;
38
- toString(): string;
8
+ export default abstract class MLDOMNode<
9
+ T extends RuleConfigValue,
10
+ O = null,
11
+ A extends MLASTAbstructNode = MLASTAbstructNode,
12
+ >
13
+ extends MLDOMToken<A>
14
+ implements IMLDOMNode
15
+ {
16
+ #private;
17
+ readonly ELEMENT_NODE = 1;
18
+ readonly ATTRIBUTE_NODE = 2;
19
+ readonly TEXT_NODE = 3;
20
+ readonly CDATA_SECTION_NODE = 4;
21
+ readonly ENTITY_REFERENCE_NODE = 5;
22
+ readonly ENTITY_NODE = 6;
23
+ readonly PROCESSING_INSTRUCTION_NODE = 7;
24
+ readonly COMMENT_NODE = 8;
25
+ readonly DOCUMENT_NODE = 9;
26
+ readonly DOCUMENT_TYPE_NODE = 10;
27
+ readonly DOCUMENT_FRAGMENT_NODE = 11;
28
+ readonly NOTATION_NODE = 12;
29
+ readonly ownerDocument: Document<T, O>;
30
+ readonly type: NodeType;
31
+ readonly rules: Record<string, AnyRule>;
32
+ protected _astToken: A;
33
+ constructor(astNode: A, document: Document<T, O>);
34
+ get childNodes(): AnonymousNode<T, O>[];
35
+ get parentNode(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
36
+ get prevNode(): AnonymousNode<T, O> | null;
37
+ get nextNode(): AnonymousNode<T, O> | null;
38
+ get syntaxicalParentNode(): MLDOMElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
39
+ get prevToken(): AnonymousNode<T, O> | null;
40
+ get nodeStore(): import('../helper').NodeStore;
41
+ get rule(): RuleInfo<T, O>;
42
+ get textContent(): string | null;
43
+ getParentElement(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
44
+ is(type: NodeType): boolean;
45
+ toString(): string;
39
46
  }
@@ -3,8 +3,11 @@ import type { IMLDOMOmittedElement } from '../types';
3
3
  import type { MLASTOmittedElement } from '@markuplint/ml-ast';
4
4
  import type { RuleConfigValue } from '@markuplint/ml-config';
5
5
  import MLDOMAbstractElement from './abstract-element';
6
- export default class MLDOMOmittedElement<T extends RuleConfigValue, O = null> extends MLDOMAbstractElement<T, O, MLASTOmittedElement> implements IMLDOMOmittedElement {
7
- readonly type = "OmittedElement";
8
- obsolete: boolean;
9
- constructor(astNode: MLASTOmittedElement, document: Document<T, O>);
6
+ export default class MLDOMOmittedElement<T extends RuleConfigValue, O = null>
7
+ extends MLDOMAbstractElement<T, O, MLASTOmittedElement>
8
+ implements IMLDOMOmittedElement
9
+ {
10
+ readonly type = 'OmittedElement';
11
+ obsolete: boolean;
12
+ constructor(astNode: MLASTOmittedElement, document: Document<T, O>);
10
13
  }
@@ -1,24 +1,24 @@
1
1
  import type { MLASTPreprocessorSpecificAttr } from '@markuplint/ml-ast';
2
2
  import MLDOMToken from './token';
3
3
  export default class MLDOMPreprocessorSpecificAttribute extends MLDOMToken<MLASTPreprocessorSpecificAttr> {
4
- readonly attrType = "ps-attr";
5
- readonly potentialName: string;
6
- readonly potentialValue: string;
7
- readonly valueType: 'string' | 'number' | 'boolean' | 'code';
8
- readonly isDuplicatable: boolean;
9
- constructor(astToken: MLASTPreprocessorSpecificAttr);
10
- getName(): {
11
- line: number;
12
- col: number;
13
- potential: string;
14
- raw: string;
15
- };
16
- getValue(): {
17
- line: number;
18
- col: number;
19
- potential: string;
20
- raw: string;
21
- };
22
- toString(): string;
23
- toNormalizeString(): string;
4
+ readonly attrType = 'ps-attr';
5
+ readonly potentialName: string;
6
+ readonly potentialValue: string;
7
+ readonly valueType: 'string' | 'number' | 'boolean' | 'code';
8
+ readonly isDuplicatable: boolean;
9
+ constructor(astToken: MLASTPreprocessorSpecificAttr);
10
+ getName(): {
11
+ line: number;
12
+ col: number;
13
+ potential: string;
14
+ raw: string;
15
+ };
16
+ getValue(): {
17
+ line: number;
18
+ col: number;
19
+ potential: string;
20
+ raw: string;
21
+ };
22
+ toString(): string;
23
+ toNormalizeString(): string;
24
24
  }
@@ -3,9 +3,12 @@ import type { IMLDOMPreprocessorSpecificBlock } from '../types';
3
3
  import type { MLASTPreprocessorSpecificBlock } from '@markuplint/ml-ast';
4
4
  import type { RuleConfigValue } from '@markuplint/ml-config';
5
5
  import MLDOMNode from './node';
6
- export default class MLDOMPreprocessorSpecificBlock<T extends RuleConfigValue, O = null> extends MLDOMNode<T, O, MLASTPreprocessorSpecificBlock> implements IMLDOMPreprocessorSpecificBlock {
7
- readonly type = "PSBlock";
8
- readonly nodeName: string;
9
- constructor(astNode: MLASTPreprocessorSpecificBlock, document: Document<T, O>);
10
- get childNodes(): AnonymousNode<T, O>[];
6
+ export default class MLDOMPreprocessorSpecificBlock<T extends RuleConfigValue, O = null>
7
+ extends MLDOMNode<T, O, MLASTPreprocessorSpecificBlock>
8
+ implements IMLDOMPreprocessorSpecificBlock
9
+ {
10
+ readonly type = 'PSBlock';
11
+ readonly nodeName: string;
12
+ constructor(astNode: MLASTPreprocessorSpecificBlock, document: Document<T, O>);
13
+ get childNodes(): AnonymousNode<T, O>[];
11
14
  }
@@ -2,14 +2,18 @@ import type { Document } from '../';
2
2
  import type { IMLDOMText } from '../types';
3
3
  import type { MLASTText } from '@markuplint/ml-ast';
4
4
  import type { RuleConfigValue } from '@markuplint/ml-config';
5
- import type { ContentModel } from '@markuplint/ml-spec';
5
+ import type { Category } from '@markuplint/ml-spec';
6
+
6
7
  import MLDOMNode from './node';
7
- export default class MLDOMText<T extends RuleConfigValue, O = null> extends MLDOMNode<T, O, MLASTText> implements IMLDOMText {
8
- readonly nodeType = 3;
9
- readonly type = "Text";
10
- readonly isRawText: boolean;
11
- readonly ownModels: Set<ContentModel>;
12
- constructor(astNode: MLASTText, document: Document<T, O>);
13
- get textContent(): string;
14
- isWhitespace(): boolean;
8
+ export default class MLDOMText<T extends RuleConfigValue, O = null>
9
+ extends MLDOMNode<T, O, MLASTText>
10
+ implements IMLDOMText
11
+ {
12
+ readonly nodeType = 3;
13
+ readonly type = 'Text';
14
+ readonly isRawText: boolean;
15
+ readonly ownModels: Set<Category>;
16
+ constructor(astNode: MLASTText, document: Document<T, O>);
17
+ get textContent(): string;
18
+ isWhitespace(): boolean;
15
19
  }