@markuplint/ml-core 2.0.0 → 2.1.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 (48) hide show
  1. package/lib/ml-core.d.ts +11 -11
  2. package/lib/ml-dom/document.d.ts +70 -66
  3. package/lib/ml-dom/document.js +23 -0
  4. package/lib/ml-dom/helper/accname.d.ts +2 -0
  5. package/lib/ml-dom/helper/accname.js +18 -0
  6. package/lib/ml-dom/helper/create-node.d.ts +1 -5
  7. package/lib/ml-dom/helper/debug.d.ts +1 -4
  8. package/lib/ml-dom/helper/debug.js +1 -1
  9. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  10. package/lib/ml-dom/helper/mapped-nodes.d.ts +3 -51
  11. package/lib/ml-dom/helper/match-selector.d.ts +6 -10
  12. package/lib/ml-dom/helper/node-store.d.ts +3 -6
  13. package/lib/ml-dom/helper/selector.d.ts +4 -4
  14. package/lib/ml-dom/helper/walkers.d.ts +2 -7
  15. package/lib/ml-dom/index.d.ts +1 -10
  16. package/lib/ml-dom/rule-mapper.d.ts +7 -7
  17. package/lib/ml-dom/tokens/abstract-element.d.ts +41 -40
  18. package/lib/ml-dom/tokens/abstract-element.js +16 -2
  19. package/lib/ml-dom/tokens/attribute.d.ts +38 -36
  20. package/lib/ml-dom/tokens/attribute.js +12 -7
  21. package/lib/ml-dom/tokens/comment.d.ts +4 -5
  22. package/lib/ml-dom/tokens/comment.js +4 -0
  23. package/lib/ml-dom/tokens/doctype.d.ts +9 -10
  24. package/lib/ml-dom/tokens/doctype.js +4 -0
  25. package/lib/ml-dom/tokens/element-close-tag.d.ts +17 -19
  26. package/lib/ml-dom/tokens/element-close-tag.js +1 -0
  27. package/lib/ml-dom/tokens/element.d.ts +15 -18
  28. package/lib/ml-dom/tokens/node.d.ts +30 -23
  29. package/lib/ml-dom/tokens/node.js +30 -15
  30. package/lib/ml-dom/tokens/omitted-element.d.ts +4 -7
  31. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +20 -20
  32. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +5 -8
  33. package/lib/ml-dom/tokens/text.d.ts +8 -9
  34. package/lib/ml-dom/tokens/text.js +4 -0
  35. package/lib/ml-dom/tokens/token.d.ts +13 -13
  36. package/lib/ml-dom/types.d.ts +13 -35
  37. package/lib/ml-rule/create-test-rule.d.ts +3 -5
  38. package/lib/ml-rule/ml-rule-context.d.ts +44 -52
  39. package/lib/ml-rule/ml-rule.d.ts +23 -33
  40. package/lib/ml-rule/types.d.ts +5 -5
  41. package/lib/plugin/types.d.ts +5 -5
  42. package/lib/ruleset/index.d.ts +4 -4
  43. package/lib/test/index.d.ts +5 -14
  44. package/lib/types.d.ts +6 -6
  45. package/lib/utils/get-location-from-chars.d.ts +4 -9
  46. package/markuplint-recommended.json +1 -0
  47. package/package.json +3 -2
  48. package/tsconfig.tsbuildinfo +1 -1
@@ -1,40 +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 attrType = 'html-attr';
5
- readonly name: MLDOMToken<MLToken>;
6
- readonly spacesBeforeName: MLDOMToken<MLToken>;
7
- readonly spacesBeforeEqual: MLDOMToken<MLToken>;
8
- readonly equal: MLDOMToken<MLToken>;
9
- readonly spacesAfterEqual: MLDOMToken<MLToken>;
10
- readonly startQuote: MLDOMToken<MLToken>;
11
- readonly value: MLDOMToken<MLToken>;
12
- readonly endQuote: MLDOMToken<MLToken>;
13
- readonly isDynamicValue?: true;
14
- readonly isDirective?: true;
15
- readonly potentialName: string;
16
- readonly candidate?: string;
17
- readonly isDuplicatable: boolean;
18
- constructor(astToken: MLASTHTMLAttr);
19
- get raw(): string;
20
- get startOffset(): number;
21
- get endOffset(): number;
22
- get startLine(): number;
23
- get endLine(): number;
24
- get startCol(): number;
25
- get endCol(): number;
26
- getName(): {
27
- line: number;
28
- col: number;
29
- potential: string;
30
- raw: string;
31
- };
32
- getValue(): {
33
- line: number;
34
- col: number;
35
- potential: string;
36
- raw: string;
37
- };
38
- toString(withSpace?: boolean): string;
39
- 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;
40
42
  }
@@ -5,6 +5,7 @@ const token_1 = (0, tslib_1.__importDefault)(require("./token"));
5
5
  class MLDOMAttribute extends token_1.default {
6
6
  constructor(astToken) {
7
7
  super(astToken);
8
+ this.nodeType = 2;
8
9
  this.attrType = 'html-attr';
9
10
  this.spacesBeforeName = new token_1.default(this._astToken.spacesBeforeName);
10
11
  this.name = new token_1.default(this._astToken.name);
@@ -12,7 +13,7 @@ class MLDOMAttribute extends token_1.default {
12
13
  this.equal = new token_1.default(this._astToken.equal);
13
14
  this.spacesAfterEqual = new token_1.default(this._astToken.spacesAfterEqual);
14
15
  this.startQuote = new token_1.default(this._astToken.startQuote);
15
- this.value = new token_1.default(this._astToken.value);
16
+ this.valueNode = new token_1.default(this._astToken.value);
16
17
  this.endQuote = new token_1.default(this._astToken.endQuote);
17
18
  this.isDynamicValue = astToken.isDynamicValue;
18
19
  this.isDirective = astToken.isDirective;
@@ -27,7 +28,7 @@ class MLDOMAttribute extends token_1.default {
27
28
  raw.push(this.equal.raw);
28
29
  raw.push(this.spacesAfterEqual.raw);
29
30
  raw.push(this.startQuote.raw);
30
- raw.push(this.value.raw);
31
+ raw.push(this.valueNode.raw);
31
32
  raw.push(this.endQuote.raw);
32
33
  }
33
34
  return raw.join('');
@@ -50,6 +51,10 @@ class MLDOMAttribute extends token_1.default {
50
51
  get endCol() {
51
52
  return this.endQuote.endCol;
52
53
  }
54
+ get value() {
55
+ const value = this.getValue();
56
+ return value.raw;
57
+ }
53
58
  getName() {
54
59
  return {
55
60
  line: this.name.startLine,
@@ -60,10 +65,10 @@ class MLDOMAttribute extends token_1.default {
60
65
  }
61
66
  getValue() {
62
67
  return {
63
- line: this.value.startLine,
64
- col: this.value.startCol,
65
- potential: this.value.raw,
66
- raw: this.value.raw,
68
+ line: this.valueNode.startLine,
69
+ col: this.valueNode.startCol,
70
+ potential: this.valueNode.raw,
71
+ raw: this.valueNode.raw,
67
72
  };
68
73
  }
69
74
  toString(withSpace = true) {
@@ -73,7 +78,7 @@ class MLDOMAttribute extends token_1.default {
73
78
  return (this.name.originRaw +
74
79
  this.equal.originRaw +
75
80
  this.startQuote.originRaw +
76
- this.value.originRaw +
81
+ this.valueNode.originRaw +
77
82
  this.endQuote.originRaw);
78
83
  }
79
84
  }
@@ -2,9 +2,8 @@ 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>
6
- extends MLDOMNode<T, O, MLASTComment>
7
- implements IMLDOMComment
8
- {
9
- readonly type = 'Comment';
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;
10
9
  }
@@ -5,7 +5,11 @@ const node_1 = (0, tslib_1.__importDefault)(require("./node"));
5
5
  class MLDOMComment extends node_1.default {
6
6
  constructor() {
7
7
  super(...arguments);
8
+ this.nodeType = 8;
8
9
  this.type = 'Comment';
9
10
  }
11
+ get textContent() {
12
+ return this.raw;
13
+ }
10
14
  }
11
15
  exports.default = MLDOMComment;
@@ -3,14 +3,13 @@ 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>
7
- extends MLDOMNode<T, O, MLASTNode>
8
- implements IMLDOMDoctype
9
- {
10
- #private;
11
- readonly type = 'Doctype';
12
- constructor(astNode: MLASTDoctype, document: Document<T, O>);
13
- get name(): string;
14
- get publicId(): string;
15
- get systemId(): string;
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;
16
15
  }
@@ -6,6 +6,7 @@ const node_1 = (0, tslib_1.__importDefault)(require("./node"));
6
6
  class MLDOMDoctype extends node_1.default {
7
7
  constructor(astNode, document) {
8
8
  super(astNode, document);
9
+ this.nodeType = 10;
9
10
  this.type = 'Doctype';
10
11
  _MLDOMDoctype_name.set(this, void 0);
11
12
  _MLDOMDoctype_publicId.set(this, void 0);
@@ -23,6 +24,9 @@ class MLDOMDoctype extends node_1.default {
23
24
  get systemId() {
24
25
  return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMDoctype_systemId, "f");
25
26
  }
27
+ get textContent() {
28
+ return null;
29
+ }
26
30
  }
27
31
  exports.default = MLDOMDoctype;
28
32
  _MLDOMDoctype_name = new WeakMap(), _MLDOMDoctype_publicId = new WeakMap(), _MLDOMDoctype_systemId = new WeakMap();
@@ -4,23 +4,21 @@ 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>
8
- extends MLDOMNode<T, O, MLASTElementCloseTag>
9
- implements IMLDOMElementCloseTag
10
- {
11
- #private;
12
- readonly type = 'ElementCloseTag';
13
- readonly nodeName: string;
14
- readonly startTag: MLDOMElement<T, O>;
15
- readonly isForeignElement: boolean;
16
- readonly isCustomElement: boolean;
17
- constructor(astNode: MLASTElementCloseTag, document: Document<T, O>, startTag: MLDOMElement<T, O>);
18
- get raw(): string;
19
- get rule(): import('@markuplint/ml-config').RuleInfo<T, O>;
20
- fixNodeName(name: string): void;
21
- getNameLocation(): {
22
- offset: number;
23
- line: number;
24
- col: number;
25
- };
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
+ };
26
24
  }
@@ -7,6 +7,7 @@ const node_1 = (0, tslib_1.__importDefault)(require("./node"));
7
7
  class MLDOMElementCloseTag extends node_1.default {
8
8
  constructor(astNode, document, startTag) {
9
9
  super(astNode, document);
10
+ this.nodeType = 1;
10
11
  this.type = 'ElementCloseTag';
11
12
  _MLDOMElementCloseTag_tagOpenChar.set(this, void 0);
12
13
  // readonly #tagCloseChar: string;
@@ -5,22 +5,19 @@ 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>
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
- };
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
+ };
26
23
  }
@@ -5,27 +5,34 @@ 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<
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 type: NodeType;
18
- readonly rules: Record<string, AnyRule>;
19
- protected _astToken: A;
20
- constructor(astNode: A, document: Document<T, O>);
21
- get parentNode(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
22
- get prevNode(): AnonymousNode<T, O> | null;
23
- get nextNode(): AnonymousNode<T, O> | null;
24
- get syntaxicalParentNode(): MLDOMElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
25
- get prevToken(): AnonymousNode<T, O> | null;
26
- get nodeStore(): import('../helper').NodeStore;
27
- get rule(): RuleInfo<T, O>;
28
- getParentElement(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
29
- is(type: NodeType): boolean;
30
- toString(): string;
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 parentNode(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
28
+ get prevNode(): AnonymousNode<T, O> | null;
29
+ get nextNode(): AnonymousNode<T, O> | null;
30
+ get syntaxicalParentNode(): MLDOMElement<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | null;
31
+ get prevToken(): AnonymousNode<T, O> | null;
32
+ get nodeStore(): import("../helper").NodeStore;
33
+ get rule(): RuleInfo<T, O>;
34
+ get textContent(): string | null;
35
+ getParentElement(): MLDOMElement<T, O> | MLDOMOmittedElement<T, O> | null;
36
+ is(type: NodeType): boolean;
37
+ toString(): string;
31
38
  }
@@ -1,39 +1,51 @@
1
1
  "use strict";
2
- var _MLDOMNode_doc, _MLDOMNode_prevToken;
2
+ var _MLDOMNode_prevToken;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const tslib_1 = require("tslib");
5
5
  const token_1 = (0, tslib_1.__importDefault)(require("./token"));
6
6
  class MLDOMNode extends token_1.default {
7
7
  constructor(astNode, document) {
8
8
  super(astNode);
9
+ // https://dom.spec.whatwg.org/#interface-node
10
+ this.ELEMENT_NODE = 1;
11
+ this.ATTRIBUTE_NODE = 2;
12
+ this.TEXT_NODE = 3;
13
+ this.CDATA_SECTION_NODE = 4;
14
+ this.ENTITY_REFERENCE_NODE = 5; // legacy
15
+ this.ENTITY_NODE = 6; // legacy
16
+ this.PROCESSING_INSTRUCTION_NODE = 7;
17
+ this.COMMENT_NODE = 8;
18
+ this.DOCUMENT_NODE = 9;
19
+ this.DOCUMENT_TYPE_NODE = 10;
20
+ this.DOCUMENT_FRAGMENT_NODE = 11;
21
+ this.NOTATION_NODE = 12; // legacy
9
22
  this.type = 'Node';
10
23
  this.rules = {};
11
- _MLDOMNode_doc.set(this, void 0);
12
24
  /**
13
25
  * prevToken cache props
14
26
  */
15
27
  _MLDOMNode_prevToken.set(this, void 0);
16
28
  this._astToken = astNode;
17
- (0, tslib_1.__classPrivateFieldSet)(this, _MLDOMNode_doc, document, "f");
18
- (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeStore.setNode(astNode, this);
29
+ this.ownerDocument = document;
30
+ this.ownerDocument.nodeStore.setNode(astNode, this);
19
31
  }
20
32
  get parentNode() {
21
33
  if (!this._astToken.parentNode) {
22
34
  return null;
23
35
  }
24
- return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeStore.getNode(this._astToken.parentNode);
36
+ return this.ownerDocument.nodeStore.getNode(this._astToken.parentNode);
25
37
  }
26
38
  get prevNode() {
27
39
  if (!this._astToken.prevNode) {
28
40
  return null;
29
41
  }
30
- return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeStore.getNode(this._astToken.prevNode);
42
+ return this.ownerDocument.nodeStore.getNode(this._astToken.prevNode);
31
43
  }
32
44
  get nextNode() {
33
45
  if (!this._astToken.nextNode) {
34
46
  return null;
35
47
  }
36
- return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeStore.getNode(this._astToken.nextNode);
48
+ return this.ownerDocument.nodeStore.getNode(this._astToken.nextNode);
37
49
  }
38
50
  get syntaxicalParentNode() {
39
51
  let parentNode = this.parentNode;
@@ -47,8 +59,8 @@ class MLDOMNode extends token_1.default {
47
59
  return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_prevToken, "f");
48
60
  }
49
61
  let index = -1;
50
- for (let i = 0; i < (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeList.length; i++) {
51
- const node = (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeList[i];
62
+ for (let i = 0; i < this.ownerDocument.nodeList.length; i++) {
63
+ const node = this.ownerDocument.nodeList[i];
52
64
  if (!node) {
53
65
  continue;
54
66
  }
@@ -64,19 +76,22 @@ class MLDOMNode extends token_1.default {
64
76
  (0, tslib_1.__classPrivateFieldSet)(this, _MLDOMNode_prevToken, null, "f");
65
77
  return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_prevToken, "f");
66
78
  }
67
- (0, tslib_1.__classPrivateFieldSet)(this, _MLDOMNode_prevToken, (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeList[index - 1] || null, "f");
79
+ (0, tslib_1.__classPrivateFieldSet)(this, _MLDOMNode_prevToken, this.ownerDocument.nodeList[index - 1] || null, "f");
68
80
  return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_prevToken, "f");
69
81
  }
70
82
  get nodeStore() {
71
- return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").nodeStore;
83
+ return this.ownerDocument.nodeStore;
72
84
  }
73
85
  get rule() {
74
- if (!(0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").currentRule) {
86
+ if (!this.ownerDocument.currentRule) {
75
87
  throw new Error('Invalid call.');
76
88
  }
77
- const name = (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").currentRule.name;
89
+ const name = this.ownerDocument.currentRule.name;
78
90
  const rule = this.rules[name];
79
- return (0, tslib_1.__classPrivateFieldGet)(this, _MLDOMNode_doc, "f").currentRule.optimizeOption(rule);
91
+ return this.ownerDocument.currentRule.optimizeOption(rule);
92
+ }
93
+ get textContent() {
94
+ return null;
80
95
  }
81
96
  getParentElement() {
82
97
  let parent = this.parentNode;
@@ -100,4 +115,4 @@ class MLDOMNode extends token_1.default {
100
115
  }
101
116
  }
102
117
  exports.default = MLDOMNode;
103
- _MLDOMNode_doc = new WeakMap(), _MLDOMNode_prevToken = new WeakMap();
118
+ _MLDOMNode_prevToken = new WeakMap();
@@ -3,11 +3,8 @@ 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>
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>);
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>);
13
10
  }
@@ -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,12 +3,9 @@ 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>
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>[];
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>[];
14
11
  }
@@ -4,13 +4,12 @@ import type { MLASTText } from '@markuplint/ml-ast';
4
4
  import type { RuleConfigValue } from '@markuplint/ml-config';
5
5
  import type { ContentModel } from '@markuplint/ml-spec';
6
6
  import MLDOMNode from './node';
7
- export default class MLDOMText<T extends RuleConfigValue, O = null>
8
- extends MLDOMNode<T, O, MLASTText>
9
- implements IMLDOMText
10
- {
11
- readonly type = 'Text';
12
- readonly isRawText: boolean;
13
- readonly ownModels: Set<ContentModel>;
14
- constructor(astNode: MLASTText, document: Document<T, O>);
15
- isWhitespace(): boolean;
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;
16
15
  }
@@ -11,10 +11,14 @@ const rawTextElements = ['script', 'style'];
11
11
  class MLDOMText extends node_1.default {
12
12
  constructor(astNode, document) {
13
13
  super(astNode, document);
14
+ this.nodeType = 3;
14
15
  this.type = 'Text';
15
16
  this.ownModels = new Set();
16
17
  this.isRawText = this.parentNode ? rawTextElements.includes(this.parentNode.nodeName.toLowerCase()) : false;
17
18
  }
19
+ get textContent() {
20
+ return this.raw;
21
+ }
18
22
  isWhitespace() {
19
23
  return /^\s+$/.test(this.raw);
20
24
  }
@@ -1,16 +1,16 @@
1
1
  import type { MLToken } from '@markuplint/ml-ast';
2
2
  export default class MLDOMToken<A extends MLToken> {
3
- #private;
4
- readonly uuid: string;
5
- protected readonly _astToken: A;
6
- constructor(astToken: A);
7
- get originRaw(): string;
8
- get raw(): string;
9
- get startOffset(): number;
10
- get endOffset(): number;
11
- get startLine(): number;
12
- get endLine(): number;
13
- get startCol(): number;
14
- get endCol(): number;
15
- fix(raw: string): void;
3
+ #private;
4
+ readonly uuid: string;
5
+ protected readonly _astToken: A;
6
+ constructor(astToken: A);
7
+ get originRaw(): string;
8
+ get raw(): string;
9
+ get startOffset(): number;
10
+ get endOffset(): number;
11
+ get startLine(): number;
12
+ get endLine(): number;
13
+ get startCol(): number;
14
+ get endCol(): number;
15
+ fix(raw: string): void;
16
16
  }