@markuplint/ml-core 4.0.0-alpha.3 → 4.0.0-alpha.5

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 (44) hide show
  1. package/LICENSE +1 -1
  2. package/lib/configs.browser.js +3 -1
  3. package/lib/configs.js +4 -5
  4. package/lib/convert-ruleset.d.ts +1 -1
  5. package/lib/convert-ruleset.js +1 -1
  6. package/lib/index.d.ts +2 -2
  7. package/lib/index.js +2 -2
  8. package/lib/ml-core.d.ts +3 -3
  9. package/lib/ml-core.js +44 -20
  10. package/lib/ml-dom/helper/accname.js +3 -3
  11. package/lib/ml-dom/helper/debug.js +11 -15
  12. package/lib/ml-dom/helper/{getIndent.js → get-indent.js} +14 -4
  13. package/lib/ml-dom/helper/walkers.js +1 -1
  14. package/lib/ml-dom/manipulations/child-node-methods.js +1 -1
  15. package/lib/ml-dom/manipulations/get-children.js +1 -1
  16. package/lib/ml-dom/node/attr.js +13 -3
  17. package/lib/ml-dom/node/character-data.js +1 -1
  18. package/lib/ml-dom/node/document-fragment.js +1 -1
  19. package/lib/ml-dom/node/document.d.ts +1 -1
  20. package/lib/ml-dom/node/document.js +57 -35
  21. package/lib/ml-dom/node/dom-token-list.js +14 -4
  22. package/lib/ml-dom/node/element.d.ts +4 -0
  23. package/lib/ml-dom/node/element.js +36 -18
  24. package/lib/ml-dom/node/named-node-map.js +1 -1
  25. package/lib/ml-dom/node/node-list.js +2 -2
  26. package/lib/ml-dom/node/node-store.js +7 -3
  27. package/lib/ml-dom/node/node.js +14 -3
  28. package/lib/ml-dom/node/parent-node.js +13 -3
  29. package/lib/ml-dom/node/rule-mapper.js +17 -7
  30. package/lib/ml-dom/node/text.js +3 -3
  31. package/lib/ml-dom/node/types.d.ts +9 -2
  32. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -1
  33. package/lib/ml-dom/node/unexpected-call-error.js +1 -1
  34. package/lib/ml-dom/token/token.js +11 -1
  35. package/lib/ml-rule/ml-rule-context.js +6 -2
  36. package/lib/ml-rule/ml-rule.d.ts +1 -1
  37. package/lib/ml-rule/ml-rule.js +12 -2
  38. package/lib/ruleset/index.d.ts +1 -1
  39. package/lib/ruleset/index.js +1 -1
  40. package/lib/test/index.js +1 -1
  41. package/lib/types.d.ts +1 -1
  42. package/lib/utils/get-location-from-chars.js +3 -3
  43. package/package.json +13 -14
  44. /package/lib/ml-dom/helper/{getIndent.d.ts → get-indent.d.ts} +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2019 Yusuke Hirao
3
+ Copyright (c) 2017-2023 Yusuke Hirao
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,7 @@
1
1
  export async function getPreset(name) {
2
- const res = await fetch(`@markuplint/config-presets/preset.${name}.json`).catch(() => new Error());
2
+ const res = await fetch(`@markuplint/config-presets/preset.${name}.json`).catch(() =>
3
+ // eslint-disable-next-line unicorn/error-message
4
+ new Error());
3
5
  if (res instanceof Error) {
4
6
  throw new ReferenceError(`Preset markuplint:${name} is not found`);
5
7
  }
package/lib/configs.js CHANGED
@@ -18,7 +18,7 @@ async function forceImportJsonInModule(modPath) {
18
18
  if (error.code !== 'ERR_IMPORT_ASSERTION_TYPE_MISSING') {
19
19
  throw error;
20
20
  }
21
- const searchPath = /Module\s"([^"]+)"\sneeds/i.exec(error.message);
21
+ const searchPath = /module\s"([^"]+)"\sneeds/i.exec(error.message);
22
22
  const absPath = searchPath?.[1] ?? null;
23
23
  log('Extract path: %s', absPath);
24
24
  if (!absPath) {
@@ -26,13 +26,12 @@ async function forceImportJsonInModule(modPath) {
26
26
  }
27
27
  const normalizePath = absPath
28
28
  .replace(/^file:\/\//, '')
29
- .replace(/\//g, path.sep)
29
+ .replaceAll('/', path.sep)
30
30
  // Windows
31
- .replace(/^[\\/][a-z]:/i, '');
31
+ .replace(/^[/\\][a-z]:/i, '');
32
32
  log('Find JSON file path: %s', normalizePath);
33
33
  const fileContent = await readFile(normalizePath, { encoding: 'utf8' });
34
- log('Success to read JSON file path: %s', normalizePath);
35
34
  return JSON.parse(fileContent);
36
35
  }
37
- return error.default ? error.default : error;
36
+ return error.default ?? error;
38
37
  }
@@ -1,3 +1,3 @@
1
1
  import type { Config } from '@markuplint/ml-config';
2
- import Ruleset from './ruleset/index.js';
2
+ import { Ruleset } from './ruleset/index.js';
3
3
  export declare function convertRuleset(config?: Config): Ruleset;
@@ -1,4 +1,4 @@
1
- import Ruleset from './ruleset/index.js';
1
+ import { Ruleset } from './ruleset/index.js';
2
2
  export function convertRuleset(config = {}) {
3
3
  return new Ruleset(config);
4
4
  }
package/lib/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { RuleInfo, RuleConfig, RuleConfigValue } from '@markuplint/ml-config';
2
2
  export { ariaSpecs, contentModelCategoryToTagNames, getAttrSpecs, getComputedRole, getImplicitRole, getPermittedRoles, getRoleSpec, getSpec, resolveNamespace, } from '@markuplint/ml-spec';
3
- export { default as Ruleset } from './ruleset/index.js';
3
+ export { Ruleset } from './ruleset/index.js';
4
4
  export { enableDebug } from './debug.js';
5
- export { getIndent } from './ml-dom/helper/getIndent.js';
5
+ export { getIndent } from './ml-dom/helper/get-indent.js';
6
6
  export * from './configs.js';
7
7
  export * from './convert-ruleset.js';
8
8
  export * from './ml-core.js';
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { ariaSpecs, contentModelCategoryToTagNames, getAttrSpecs, getComputedRole, getImplicitRole, getPermittedRoles, getRoleSpec, getSpec, resolveNamespace, } from '@markuplint/ml-spec';
2
- export { default as Ruleset } from './ruleset/index.js';
2
+ export { Ruleset } from './ruleset/index.js';
3
3
  export { enableDebug } from './debug.js';
4
- export { getIndent } from './ml-dom/helper/getIndent.js';
4
+ export { getIndent } from './ml-dom/helper/get-indent.js';
5
5
  export * from './configs.js';
6
6
  export * from './convert-ruleset.js';
7
7
  export * from './ml-core.js';
package/lib/ml-core.d.ts CHANGED
@@ -9,10 +9,10 @@ export 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);
13
- get document(): ParserError | Document<RuleConfigValue, PlainData>;
12
+ constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, configErrors, }: MLCoreParams);
13
+ get document(): Document<RuleConfigValue, PlainData> | ParserError;
14
14
  setCode(sourceCode: string): void;
15
- update({ parser, ruleset, rules, locale, schemas, parserOptions }: Partial<MLFabric>): void;
15
+ update({ parser, ruleset, rules, locale, schemas, parserOptions, configErrors }: Partial<MLFabric>): void;
16
16
  verify(fix?: boolean): Promise<Violation[]>;
17
17
  private _createDocument;
18
18
  private _parse;
package/lib/ml-core.js CHANGED
@@ -1,11 +1,21 @@
1
- var _MLCore_ast, _MLCore_document, _MLCore_filename, _MLCore_locale, _MLCore_parser, _MLCore_parserOptions, _MLCore_pretenders, _MLCore_rules, _MLCore_ruleset, _MLCore_schemas, _MLCore_sourceCode;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _MLCore_ast, _MLCore_document, _MLCore_filename, _MLCore_locale, _MLCore_parser, _MLCore_parserOptions, _MLCore_pretenders, _MLCore_rules, _MLCore_ruleset, _MLCore_schemas, _MLCore_sourceCode, _MLCore_configErrors;
3
13
  import { ParserError } from '@markuplint/parser-utils';
4
14
  import { log, enableDebug } from './debug.js';
5
15
  import { Document } from './ml-dom/index.js';
6
16
  const resultLog = log.extend('result');
7
17
  export class MLCore {
8
- constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, }) {
18
+ constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, configErrors, }) {
9
19
  _MLCore_ast.set(this, null);
10
20
  _MLCore_document.set(this, void 0);
11
21
  _MLCore_filename.set(this, void 0);
@@ -17,6 +27,7 @@ export class MLCore {
17
27
  _MLCore_ruleset.set(this, void 0);
18
28
  _MLCore_schemas.set(this, void 0);
19
29
  _MLCore_sourceCode.set(this, void 0);
30
+ _MLCore_configErrors.set(this, void 0);
20
31
  if (debug) {
21
32
  enableDebug();
22
33
  }
@@ -31,8 +42,9 @@ export class MLCore {
31
42
  __classPrivateFieldSet(this, _MLCore_locale, locale, "f");
32
43
  __classPrivateFieldSet(this, _MLCore_schemas, schemas, "f");
33
44
  __classPrivateFieldSet(this, _MLCore_filename, filename, "f");
34
- __classPrivateFieldSet(this, _MLCore_rules, rules.slice(), "f");
35
- __classPrivateFieldSet(this, _MLCore_pretenders, pretenders.slice(), "f");
45
+ __classPrivateFieldSet(this, _MLCore_rules, [...rules], "f");
46
+ __classPrivateFieldSet(this, _MLCore_pretenders, [...pretenders], "f");
47
+ __classPrivateFieldSet(this, _MLCore_configErrors, [...(configErrors ?? [])], "f");
36
48
  this._parse();
37
49
  this._createDocument();
38
50
  }
@@ -44,7 +56,7 @@ export class MLCore {
44
56
  this._parse();
45
57
  this._createDocument();
46
58
  }
47
- update({ parser, ruleset, rules, locale, schemas, parserOptions }) {
59
+ update({ parser, ruleset, rules, locale, schemas, parserOptions, configErrors }) {
48
60
  __classPrivateFieldSet(this, _MLCore_parser, parser ?? __classPrivateFieldGet(this, _MLCore_parser, "f"), "f");
49
61
  __classPrivateFieldSet(this, _MLCore_ruleset, {
50
62
  rules: ruleset?.rules ?? __classPrivateFieldGet(this, _MLCore_ruleset, "f").rules,
@@ -54,6 +66,7 @@ export class MLCore {
54
66
  __classPrivateFieldSet(this, _MLCore_rules, rules?.slice() ?? __classPrivateFieldGet(this, _MLCore_rules, "f"), "f");
55
67
  __classPrivateFieldSet(this, _MLCore_locale, locale ?? __classPrivateFieldGet(this, _MLCore_locale, "f"), "f");
56
68
  __classPrivateFieldSet(this, _MLCore_schemas, schemas ?? __classPrivateFieldGet(this, _MLCore_schemas, "f"), "f");
69
+ __classPrivateFieldSet(this, _MLCore_configErrors, [...(configErrors ?? [])], "f");
57
70
  if (parserOptions &&
58
71
  (parserOptions.ignoreFrontMatter !== __classPrivateFieldGet(this, _MLCore_parserOptions, "f").ignoreFrontMatter ||
59
72
  parserOptions.authoredElementName !== __classPrivateFieldGet(this, _MLCore_parserOptions, "f").authoredElementName)) {
@@ -76,17 +89,27 @@ export class MLCore {
76
89
  log('verify: error %o', __classPrivateFieldGet(this, _MLCore_document, "f").message);
77
90
  return violations;
78
91
  }
92
+ for (const error of __classPrivateFieldGet(this, _MLCore_configErrors, "f")) {
93
+ violations.push({
94
+ ruleId: 'config-error',
95
+ severity: 'warning',
96
+ message: error.message,
97
+ col: 1,
98
+ line: 1,
99
+ raw: '',
100
+ });
101
+ }
79
102
  for (const rule of __classPrivateFieldGet(this, _MLCore_rules, "f")) {
80
103
  const ruleInfo = rule.getRuleInfo(__classPrivateFieldGet(this, _MLCore_ruleset, "f"), rule.name);
81
104
  if (ruleInfo.disabled && ruleInfo.nodeRules.length === 0 && ruleInfo.childNodeRules.length === 0) {
82
105
  continue;
83
106
  }
84
107
  log('%s Rule: verify', rule.name);
85
- const results = await rule.verify(__classPrivateFieldGet(this, _MLCore_document, "f"), __classPrivateFieldGet(this, _MLCore_locale, "f"), fix).catch(e => {
86
- if (e instanceof ParserError) {
87
- return e;
108
+ const results = await rule.verify(__classPrivateFieldGet(this, _MLCore_document, "f"), __classPrivateFieldGet(this, _MLCore_locale, "f"), fix).catch(error => {
109
+ if (error instanceof ParserError) {
110
+ return error;
88
111
  }
89
- throw e;
112
+ throw error;
90
113
  });
91
114
  if (results instanceof ParserError) {
92
115
  log('%s Rule: verify error %o', rule.name, results.message);
@@ -105,6 +128,7 @@ export class MLCore {
105
128
  log('%s Rule: verify end', rule.name);
106
129
  }
107
130
  if (resultLog.enabled) {
131
+ // eslint-disable-next-line unicorn/no-array-reduce
108
132
  const { e, w, i } = violations.reduce((c, v) => {
109
133
  if (v.severity === 'error')
110
134
  c.e += 1;
@@ -133,12 +157,12 @@ export class MLCore {
133
157
  pretenders: __classPrivateFieldGet(this, _MLCore_pretenders, "f"),
134
158
  }), "f");
135
159
  }
136
- catch (err) {
137
- if (err instanceof ParserError) {
138
- __classPrivateFieldSet(this, _MLCore_document, err, "f");
160
+ catch (error) {
161
+ if (error instanceof ParserError) {
162
+ __classPrivateFieldSet(this, _MLCore_document, error, "f");
139
163
  }
140
164
  else {
141
- throw err;
165
+ throw error;
142
166
  }
143
167
  }
144
168
  }
@@ -146,16 +170,16 @@ export class MLCore {
146
170
  try {
147
171
  __classPrivateFieldSet(this, _MLCore_ast, __classPrivateFieldGet(this, _MLCore_parser, "f").parse(__classPrivateFieldGet(this, _MLCore_sourceCode, "f"), __classPrivateFieldGet(this, _MLCore_parserOptions, "f")), "f");
148
172
  }
149
- catch (err) {
150
- log('Caught the parse error: %O', err);
173
+ catch (error) {
174
+ log('Caught the parse error: %O', error);
151
175
  __classPrivateFieldSet(this, _MLCore_ast, null, "f");
152
- if (err instanceof ParserError) {
153
- __classPrivateFieldSet(this, _MLCore_document, err, "f");
176
+ if (error instanceof ParserError) {
177
+ __classPrivateFieldSet(this, _MLCore_document, error, "f");
154
178
  }
155
179
  else {
156
- throw err;
180
+ throw error;
157
181
  }
158
182
  }
159
183
  }
160
184
  }
161
- _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();
185
+ _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(), _MLCore_configErrors = new WeakMap();
@@ -16,7 +16,7 @@ el, version) {
16
16
  return '';
17
17
  }
18
18
  if (isFromContent(el, version)) {
19
- return Array.from(el.childNodes)
19
+ return [...el.childNodes]
20
20
  .map(child => {
21
21
  if (child.is(child.ELEMENT_NODE)) {
22
22
  return getAccname(child, version);
@@ -37,9 +37,9 @@ el) {
37
37
  const name = get(el);
38
38
  return name;
39
39
  }
40
- catch (err) {
40
+ catch (error) {
41
41
  accnameLog('Raw: %s', el.raw);
42
- accnameLog('Error: %O', err);
42
+ accnameLog('Error: %O', error);
43
43
  return '';
44
44
  }
45
45
  }
@@ -1,8 +1,7 @@
1
1
  export function nodeListToDebugMaps(
2
2
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
3
3
  nodeList, withAttr = false) {
4
- return nodeList
5
- .map(n => {
4
+ return nodeList.flatMap(n => {
6
5
  const r = [];
7
6
  if (n.is(n.ELEMENT_NODE) && n.isOmitted) {
8
7
  r.push(`[N/A]>[N/A](N/A)${n.nodeName}: ${visibleWhiteSpace(n.raw)}`);
@@ -10,10 +9,9 @@ nodeList, withAttr = false) {
10
9
  }
11
10
  r.push(tokenDebug(n));
12
11
  if (n.is(n.ELEMENT_NODE)) {
13
- r.push(` namespaceURI: ${!!n.namespaceURI}`);
14
- r.push(` elementType: ${n.elementType}`);
15
- r.push(` isInFragmentDocument: ${n.isInFragmentDocument()}`);
16
- r.push(` isForeignElement: ${!!n.isForeignElement}`);
12
+ r.push(
13
+ //
14
+ ` namespaceURI: ${!!n.namespaceURI}`, ` elementType: ${n.elementType}`, ` isInFragmentDocument: ${n.isInFragmentDocument()}`, ` isForeignElement: ${!!n.isForeignElement}`);
17
15
  if (withAttr) {
18
16
  r.push(...attributesToDebugMaps(n.attributes)
19
17
  .flat()
@@ -21,14 +19,12 @@ nodeList, withAttr = false) {
21
19
  }
22
20
  }
23
21
  return r;
24
- })
25
- .flat();
22
+ });
26
23
  }
27
24
  function attributesToDebugMaps(
28
25
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
29
26
  attributes) {
30
- return attributes
31
- .map(n => {
27
+ return attributes.flatMap(n => {
32
28
  const r = [
33
29
  tokenDebug({
34
30
  name: n.name,
@@ -66,19 +62,19 @@ attributes) {
66
62
  r.push(` ${tokenDebug(n.endQuote, 'eQ')}`);
67
63
  }
68
64
  if (n.spacesBeforeName) {
69
- r.push(` isDirective: ${!!n.isDirective}`);
70
- r.push(` isDynamicValue: ${!!n.isDynamicValue}`);
65
+ r.push(
66
+ //
67
+ ` isDirective: ${!!n.isDirective}`, ` isDynamicValue: ${!!n.isDynamicValue}`);
71
68
  }
72
69
  if (n.candidate) {
73
70
  r.push(` candidate: ${visibleWhiteSpace(n.candidate)}`);
74
71
  }
75
72
  return r;
76
- })
77
- .flat();
73
+ });
78
74
  }
79
75
  function tokenDebug(n, type = '') {
80
76
  return `[${n.startLine}:${n.startCol}]>[${n.endLine}:${n.endCol}](${n.startOffset},${n.endOffset})${n.nodeName ?? n.potentialName ?? n.name ?? n.type ?? type}: ${visibleWhiteSpace(n.raw)}`;
81
77
  }
82
78
  function visibleWhiteSpace(chars) {
83
- return chars.replace(/\n/g, '⏎').replace(/\t/g, '→').replace(/\s/g, '␣');
79
+ return chars.replaceAll('\n', '⏎').replaceAll('\t', '→').replaceAll(/\s/g, '␣');
84
80
  }
@@ -1,5 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
1
12
  var _MLDOMIndentation_fixed, _MLDOMIndentation_node, _MLDOMIndentation_parent;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
13
  /**
4
14
  *
5
15
  * @deprecated
@@ -16,7 +26,7 @@ node) {
16
26
  if (node.isRawTextElementContent()) {
17
27
  return null;
18
28
  }
19
- const matched = node.raw.match(/^(\s*(?:\r?\n)+\s*)(?:[^\s]+)/);
29
+ const matched = node.raw.match(/^([\t\v\f\r \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\n\s*)\S+/);
20
30
  if (matched) {
21
31
  const spaces = matched[1];
22
32
  if (spaces) {
@@ -36,8 +46,8 @@ node) {
36
46
  // One or more newlines and zero or more spaces or tabs.
37
47
  // Or, If textNode is first token and that is filled spaces, tabs and newlines only.
38
48
  const matched = isFirstToken(prevToken)
39
- ? prevToken.raw.match(/^(?:[ \t]*\r?\n)*([ \t]*)$/)
40
- : prevToken.raw.match(/\r?\n([ \t]*)$/);
49
+ ? prevToken.raw.match(/^(?:[\t ]*\r?\n)*([\t ]*)$/)
50
+ : prevToken.raw.match(/\r?\n([\t ]*)$/);
41
51
  // console.log({ [`${this}`]: matched, _: prevToken.raw, f: prevToken._isFirstToken() });
42
52
  if (matched) {
43
53
  // Spaces will include empty string.
@@ -3,7 +3,7 @@ export function syncWalk(
3
3
  nodeList, walker) {
4
4
  for (const node of nodeList) {
5
5
  if (node.is(node.ELEMENT_NODE) || node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK)) {
6
- syncWalk(Array.from(node.childNodes), walker);
6
+ syncWalk([...node.childNodes], walker);
7
7
  }
8
8
  walker(node);
9
9
  }
@@ -1,4 +1,4 @@
1
- import UnexpectedCallError from '../node/unexpected-call-error.js';
1
+ import { UnexpectedCallError } from '../node/unexpected-call-error.js';
2
2
  /**
3
3
  *
4
4
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
@@ -2,7 +2,7 @@ import { toHTMLCollection } from '../node/node-list.js';
2
2
  export function getChildren(
3
3
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
4
4
  node) {
5
- return toHTMLCollection(Array.from(node.childNodes).filter((child) => {
5
+ return toHTMLCollection([...node.childNodes].filter((child) => {
6
6
  return child.nodeType === child.ELEMENT_NODE;
7
7
  }));
8
8
  }
@@ -1,10 +1,20 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
1
12
  var _MLAttr_localName, _MLAttr_namespaceURI, _MLAttr_potentialName, _MLAttr_potentialValue;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
13
  import { resolveNamespace } from '@markuplint/ml-spec';
4
14
  import { MLToken } from '../token/token.js';
5
15
  import { MLDomTokenList } from './dom-token-list.js';
6
16
  import { MLNode } from './node.js';
7
- import UnexpectedCallError from './unexpected-call-error.js';
17
+ import { UnexpectedCallError } from './unexpected-call-error.js';
8
18
  export class MLAttr extends MLNode {
9
19
  constructor(
10
20
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
@@ -44,7 +54,7 @@ export class MLAttr extends MLNode {
44
54
  this.isDirective = this._astToken.isDirective;
45
55
  this.candidate = this._astToken.candidate;
46
56
  __classPrivateFieldSet(this, _MLAttr_potentialName, this._astToken.potentialName ?? this.nameNode?.raw ?? '', "f");
47
- __classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.value.raw ?? '', "f");
57
+ __classPrivateFieldSet(this, _MLAttr_potentialValue, this._astToken.potentialValue ?? this.valueNode?.raw ?? '', "f");
48
58
  }
49
59
  else {
50
60
  this.valueType = this._astToken.valueType;
@@ -1,6 +1,6 @@
1
1
  import { after, before, nextElementSibling, previousElementSibling, remove, replaceWith, } from '../manipulations/child-node-methods.js';
2
2
  import { MLNode } from './node.js';
3
- import UnexpectedCallError from './unexpected-call-error.js';
3
+ import { UnexpectedCallError } from './unexpected-call-error.js';
4
4
  export class MLCharacterData extends MLNode {
5
5
  /**
6
6
  * @implements DOM API: `CharacterData`
@@ -1,5 +1,5 @@
1
1
  import { MLParentNode } from './parent-node.js';
2
- import UnexpectedCallError from './unexpected-call-error.js';
2
+ import { UnexpectedCallError } from './unexpected-call-error.js';
3
3
  export class MLDocumentFragment extends MLParentNode {
4
4
  /**
5
5
  * Returns a string appropriate for the type of node as `DocumentFragment`
@@ -6,7 +6,7 @@ import type { MLNode } from './node.js';
6
6
  import type { MLText } from './text.js';
7
7
  import type { AccessibilityProperties, DocumentNodeType } from './types.js';
8
8
  import type { MLRule } from '../../ml-rule/index.js';
9
- import type Ruleset from '../../ruleset/index.js';
9
+ import type { Ruleset } from '../../ruleset/index.js';
10
10
  import type { MLSchema } from '../../types.js';
11
11
  import type { Walker } from '../helper/walkers.js';
12
12
  import type { MLToken } from '../token/token.js';