@markuplint/ml-core 4.0.0-alpha.1 → 4.0.0-alpha.11

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 (61) hide show
  1. package/LICENSE +1 -1
  2. package/lib/configs.browser.js +10 -6
  3. package/lib/convert-ruleset.d.ts +1 -1
  4. package/lib/convert-ruleset.js +1 -1
  5. package/lib/index.d.ts +3 -3
  6. package/lib/index.js +2 -3
  7. package/lib/ml-core.d.ts +3 -3
  8. package/lib/ml-core.js +44 -20
  9. package/lib/ml-dom/helper/accname.js +3 -3
  10. package/lib/ml-dom/helper/create-node.d.ts +2 -2
  11. package/lib/ml-dom/helper/create-node.js +32 -7
  12. package/lib/ml-dom/helper/debug.js +11 -15
  13. package/lib/ml-dom/helper/{getIndent.js → get-indent.js} +14 -4
  14. package/lib/ml-dom/helper/walkers.js +1 -1
  15. package/lib/ml-dom/manipulations/child-node-methods.js +1 -1
  16. package/lib/ml-dom/manipulations/get-children.js +1 -1
  17. package/lib/ml-dom/node/attr.d.ts +18 -0
  18. package/lib/ml-dom/node/attr.js +80 -32
  19. package/lib/ml-dom/node/block.js +1 -3
  20. package/lib/ml-dom/node/character-data.d.ts +2 -2
  21. package/lib/ml-dom/node/character-data.js +1 -1
  22. package/lib/ml-dom/node/child-node.d.ts +2 -2
  23. package/lib/ml-dom/node/document-fragment.d.ts +2 -2
  24. package/lib/ml-dom/node/document-fragment.js +1 -1
  25. package/lib/ml-dom/node/document-type.js +1 -3
  26. package/lib/ml-dom/node/document.d.ts +7 -5
  27. package/lib/ml-dom/node/document.js +105 -39
  28. package/lib/ml-dom/node/dom-token-list.js +15 -5
  29. package/lib/ml-dom/node/element-close-tag.d.ts +20 -0
  30. package/lib/ml-dom/node/element-close-tag.js +39 -0
  31. package/lib/ml-dom/node/element.d.ts +51 -6
  32. package/lib/ml-dom/node/element.js +139 -62
  33. package/lib/ml-dom/node/named-node-map.js +1 -1
  34. package/lib/ml-dom/node/node-list.js +2 -2
  35. package/lib/ml-dom/node/node-store.d.ts +3 -3
  36. package/lib/ml-dom/node/node-store.js +7 -3
  37. package/lib/ml-dom/node/node.d.ts +2 -2
  38. package/lib/ml-dom/node/node.js +31 -13
  39. package/lib/ml-dom/node/parent-node.d.ts +2 -2
  40. package/lib/ml-dom/node/parent-node.js +13 -3
  41. package/lib/ml-dom/node/rule-mapper.js +17 -7
  42. package/lib/ml-dom/node/text.js +3 -3
  43. package/lib/ml-dom/node/types.d.ts +23 -3
  44. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -1
  45. package/lib/ml-dom/node/unexpected-call-error.js +1 -1
  46. package/lib/ml-dom/token/token.d.ts +3 -3
  47. package/lib/ml-dom/token/token.js +16 -6
  48. package/lib/ml-rule/ml-rule-context.js +6 -2
  49. package/lib/ml-rule/ml-rule.d.ts +1 -1
  50. package/lib/ml-rule/ml-rule.js +12 -2
  51. package/lib/ml-rule/types.d.ts +3 -0
  52. package/lib/ruleset/index.d.ts +1 -1
  53. package/lib/ruleset/index.js +1 -1
  54. package/lib/test/index.d.ts +6 -4
  55. package/lib/test/index.js +7 -3
  56. package/lib/types.d.ts +3 -3
  57. package/lib/utils/get-location-from-chars.js +3 -3
  58. package/package.json +13 -14
  59. package/lib/configs.d.ts +0 -2
  60. package/lib/configs.js +0 -37
  61. /package/lib/ml-dom/helper/{getIndent.d.ts → get-indent.d.ts} +0 -0
@@ -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,9 +1,9 @@
1
1
  import type { MLBlock } from './block.js';
2
2
  import type { MLCharacterData } from './character-data.js';
3
- import type { MLDocumentType } from './document-type.js';
3
+ import type { MLComment } from './comment.js';
4
4
  import type { MLElement } from './element.js';
5
5
  import type { MLNode } from './node.js';
6
6
  import type { MLText } from './text.js';
7
7
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
8
- export type MLChildNode<T extends RuleConfigValue, O extends PlainData = undefined> = MLDocumentType<T, O> | MLCharacterData<T, O> | MLText<T, O> | MLElement<T, O> | MLBlock<T, O>;
8
+ export type MLChildNode<T extends RuleConfigValue, O extends PlainData = undefined> = MLCharacterData<T, O> | MLComment<T, O> | MLText<T, O> | MLElement<T, O> | MLBlock<T, O>;
9
9
  export declare function isChildNode<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): node is MLChildNode<T, O>;
@@ -1,8 +1,8 @@
1
1
  import type { DocumentFragmentNodeType } from './types.js';
2
- import type { MLASTAbstractNode } from '@markuplint/ml-ast';
2
+ import type { MLASTNode } from '@markuplint/ml-ast';
3
3
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  import { MLParentNode } from './parent-node.js';
5
- export declare class MLDocumentFragment<T extends RuleConfigValue, O extends PlainData = undefined> extends MLParentNode<T, O, MLASTAbstractNode> implements DocumentFragment {
5
+ export declare class MLDocumentFragment<T extends RuleConfigValue, O extends PlainData = undefined> extends MLParentNode<T, O, MLASTNode> implements DocumentFragment {
6
6
  /**
7
7
  * Returns a string appropriate for the type of node as `DocumentFragment`
8
8
  *
@@ -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`
@@ -1,9 +1,7 @@
1
1
  import { after, before, remove, replaceWith } from '../manipulations/child-node-methods.js';
2
2
  import { MLNode } from './node.js';
3
3
  export class MLDocumentType extends MLNode {
4
- constructor(
5
- // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
- astNode,
4
+ constructor(astNode,
7
5
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
6
  document) {
9
7
  super(astNode, document);
@@ -4,9 +4,9 @@ import type { MLDocumentType } from './document-type.js';
4
4
  import type { MLElement } from './element.js';
5
5
  import type { MLNode } from './node.js';
6
6
  import type { MLText } from './text.js';
7
- import type { DocumentNodeType } from './types.js';
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';
@@ -933,6 +933,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
933
933
  * @implements DOM API: `Document`
934
934
  */
935
935
  get onscroll(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
936
+ get onscrollend(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
936
937
  /**
937
938
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
938
939
  *
@@ -1428,6 +1429,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1428
1429
  * @implements DOM API: `Document`
1429
1430
  */
1430
1431
  exitPointerLock(): void;
1432
+ getAccessibilityProp(node: MLNode<T, O>, ariaVersion?: "1.2"): AccessibilityProperties | null;
1431
1433
  /**
1432
1434
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1433
1435
  *
@@ -1477,7 +1479,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1477
1479
  /**
1478
1480
  * @implements `@markuplint/ml-core` API: `MLDocument`
1479
1481
  */
1480
- getTokenList(): readonly MLToken<import("@markuplint/ml-ast").MLToken>[];
1482
+ getTokenList(): readonly MLToken<import("@markuplint/ml-ast").MLASTToken>[];
1481
1483
  /**
1482
1484
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1483
1485
  *
@@ -1564,7 +1566,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1564
1566
  /**
1565
1567
  * @implements `@markuplint/ml-core` API: `MLDocument`
1566
1568
  */
1567
- searchNodeByLocation(line: number, col: number): MLNode<T, O, import("@markuplint/ml-ast").MLASTAbstractNode> | null;
1569
+ searchNodeByLocation(line: number, col: number): MLNode<T, O, import("@markuplint/ml-ast").MLASTNode> | null;
1568
1570
  /**
1569
1571
  * @implements `@markuplint/ml-core` API: `MLDocument`
1570
1572
  */
@@ -1572,7 +1574,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1572
1574
  /**
1573
1575
  * @implements `@markuplint/ml-core` API: `MLDocument`
1574
1576
  */
1575
- toString(): string;
1577
+ toString(fixed?: boolean): string;
1576
1578
  /**
1577
1579
  * @implements `@markuplint/ml-core` API: `MLDocument`
1578
1580
  */
@@ -1,7 +1,17 @@
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 _MLDocument_filename, _MLDocument_tokenList;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
13
  import { exchangeValueOnRule, mergeRule } from '@markuplint/ml-config';
4
- import { schemaToSpec } from '@markuplint/ml-spec';
14
+ import { schemaToSpec, getAccname, getComputedRole, mayBeFocusable, getComputedAriaProps, isExposed, ARIA_RECOMMENDED_VERSION, } from '@markuplint/ml-spec';
5
15
  import { ConfigParserError } from '@markuplint/parser-utils';
6
16
  import { InvalidSelectorError, matchSelector } from '@markuplint/selector';
7
17
  import { log as coreLog } from '../../debug.js';
@@ -11,7 +21,7 @@ import { sequentialWalker, syncWalk } from '../helper/walkers.js';
11
21
  import { nodeListToHTMLCollection } from './node-list.js';
12
22
  import { MLParentNode } from './parent-node.js';
13
23
  import { RuleMapper } from './rule-mapper.js';
14
- import UnexpectedCallError from './unexpected-call-error.js';
24
+ import { UnexpectedCallError } from './unexpected-call-error.js';
15
25
  const log = coreLog.extend('ml-dom');
16
26
  const docLog = log.extend('document');
17
27
  const ruleLog = docLog.extend('rule');
@@ -21,9 +31,7 @@ export class MLDocument extends MLParentNode {
21
31
  * @param ast node list of markuplint AST
22
32
  * @param ruleset ruleset object
23
33
  */
24
- constructor(
25
- // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
26
- ast, ruleset, schemas, options) {
34
+ constructor(ast, ruleset, schemas, options) {
27
35
  // @ts-ignore
28
36
  super(ast, null);
29
37
  /**
@@ -1170,6 +1178,9 @@ export class MLDocument extends MLParentNode {
1170
1178
  get onscroll() {
1171
1179
  throw new UnexpectedCallError('Not supported "onscroll" property');
1172
1180
  }
1181
+ get onscrollend() {
1182
+ throw new UnexpectedCallError('Not supported "onscrollend" property');
1183
+ }
1173
1184
  /**
1174
1185
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1175
1186
  *
@@ -1821,6 +1832,58 @@ export class MLDocument extends MLParentNode {
1821
1832
  exitPointerLock() {
1822
1833
  throw new UnexpectedCallError('Not supported "exitPointerLock" method');
1823
1834
  }
1835
+ getAccessibilityProp(
1836
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1837
+ node, ariaVersion = ARIA_RECOMMENDED_VERSION) {
1838
+ if (!node.is(node.ELEMENT_NODE)) {
1839
+ return null;
1840
+ }
1841
+ if (['slot'].includes(node.localName)) {
1842
+ return {
1843
+ unknown: true,
1844
+ };
1845
+ }
1846
+ const exposed = isExposed(node, node.ownerMLDocument.specs, ariaVersion);
1847
+ if (!exposed) {
1848
+ return {
1849
+ unknown: false,
1850
+ exposedToTree: false,
1851
+ };
1852
+ }
1853
+ const aria = {
1854
+ unknown: false,
1855
+ exposedToTree: true,
1856
+ };
1857
+ const role = getComputedRole(node.ownerMLDocument.specs, node, ariaVersion);
1858
+ const name = getAccname(node).trim();
1859
+ const focusable = mayBeFocusable(node, node.ownerMLDocument.specs);
1860
+ const nameRequired = role.role?.accessibleNameRequired ?? false;
1861
+ const nameProhibited = role.role?.accessibleNameProhibited ?? false;
1862
+ const hasSlot = !!node.querySelector('slot');
1863
+ aria.role = role.role?.name;
1864
+ aria.nameRequired = nameRequired;
1865
+ aria.nameProhibited = nameProhibited;
1866
+ aria.name =
1867
+ name ||
1868
+ (hasSlot
1869
+ ? {
1870
+ unknown: true,
1871
+ }
1872
+ : '');
1873
+ aria.focusable = focusable;
1874
+ for (const prop of Object.values(getComputedAriaProps(node.ownerMLDocument.specs, node, ariaVersion))) {
1875
+ if (!prop.required && prop.from === 'default') {
1876
+ continue;
1877
+ }
1878
+ aria.props = aria.props || {};
1879
+ const propName = prop.name.replace('aria-', '');
1880
+ aria.props[propName] = {
1881
+ value: prop.value ?? null,
1882
+ required: prop.required,
1883
+ };
1884
+ }
1885
+ return aria;
1886
+ }
1824
1887
  /**
1825
1888
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1826
1889
  *
@@ -2025,12 +2088,18 @@ export class MLDocument extends MLParentNode {
2025
2088
  /**
2026
2089
  * @implements `@markuplint/ml-core` API: `MLDocument`
2027
2090
  */
2028
- toString() {
2029
- const html = [];
2091
+ toString(fixed = false) {
2092
+ if (!fixed) {
2093
+ return this.raw;
2094
+ }
2095
+ let raw = this.raw;
2096
+ let offset = 0;
2030
2097
  for (const node of this.getTokenList()) {
2031
- html.push(node.toString());
2098
+ const nodeRaw = node.toString(true);
2099
+ raw = raw.slice(0, node.startOffset + offset) + nodeRaw + raw.slice(node.endOffset + offset);
2100
+ offset += nodeRaw.length - (node.endOffset - node.startOffset);
2032
2101
  }
2033
- return html.join('');
2102
+ return raw;
2034
2103
  }
2035
2104
  walkOn(type, walker, skipWhenRuleIsDisabled = true) {
2036
2105
  return sequentialWalker(this.nodeList, node => {
@@ -2047,7 +2116,7 @@ export class MLDocument extends MLParentNode {
2047
2116
  return walker(node);
2048
2117
  }
2049
2118
  if (type === 'Attr' && node.is(node.ELEMENT_NODE)) {
2050
- return sequentialWalker(Array.from(node.attributes), attr => walker(attr));
2119
+ return sequentialWalker([...node.attributes], attr => walker(attr));
2051
2120
  }
2052
2121
  if (type === 'ElementCloseTag' && node.is(node.ELEMENT_NODE) && node.closeTag) {
2053
2122
  return walker(node.closeTag);
@@ -2076,9 +2145,6 @@ export class MLDocument extends MLParentNode {
2076
2145
  if (docLog.enabled) {
2077
2146
  docLog('Pretending: %O', pretenders);
2078
2147
  }
2079
- if (!pretenders) {
2080
- return;
2081
- }
2082
2148
  for (const node of this.nodeList) {
2083
2149
  if (node.is(node.ELEMENT_NODE)) {
2084
2150
  node.pretending(pretenders);
@@ -2091,50 +2157,50 @@ export class MLDocument extends MLParentNode {
2091
2157
  }
2092
2158
  const ruleMapper = new RuleMapper(this);
2093
2159
  // global rules to #document
2094
- Object.keys(ruleset.rules).forEach(ruleName => {
2160
+ for (const ruleName of Object.keys(ruleset.rules)) {
2095
2161
  const rule = ruleset.rules[ruleName];
2096
2162
  if (rule == null) {
2097
- return;
2163
+ continue;
2098
2164
  }
2099
2165
  ruleMapper.set(this, ruleName, {
2100
2166
  from: 'rules',
2101
2167
  specificity: [0, 0, 0],
2102
2168
  rule,
2103
2169
  });
2104
- });
2170
+ }
2105
2171
  // add rules to node
2106
2172
  for (const node of this.nodeList) {
2107
2173
  if (docLog.enabled) {
2108
2174
  docLog('Add rules to node <%s>', node.nodeName);
2109
2175
  }
2110
2176
  // global rules to each element
2111
- Object.keys(ruleset.rules).forEach(ruleName => {
2177
+ for (const ruleName of Object.keys(ruleset.rules)) {
2112
2178
  const rule = ruleset.rules[ruleName];
2113
2179
  if (rule == null) {
2114
- return;
2180
+ continue;
2115
2181
  }
2116
2182
  ruleMapper.set(node, ruleName, {
2117
2183
  from: 'rules',
2118
2184
  specificity: [0, 0, 0],
2119
2185
  rule,
2120
2186
  });
2121
- });
2187
+ }
2122
2188
  if (!node.is(node.ELEMENT_NODE) && !node.is(node.TEXT_NODE)) {
2123
2189
  continue;
2124
2190
  }
2125
2191
  const selectorTarget = node.is(node.ELEMENT_NODE) ? node : null;
2126
2192
  // node specs and special rules for node by selector
2127
- ruleset.nodeRules.forEach(nodeRule => {
2193
+ for (const nodeRule of ruleset.nodeRules) {
2128
2194
  if (!nodeRule.rules) {
2129
- return;
2195
+ continue;
2130
2196
  }
2131
2197
  if (!selectorTarget) {
2132
- return;
2198
+ continue;
2133
2199
  }
2134
2200
  const selector = nodeRule.selector ?? nodeRule.regexSelector;
2135
2201
  const matches = matchSelector(selectorTarget, selector);
2136
2202
  if (!matches.matched) {
2137
- return;
2203
+ continue;
2138
2204
  }
2139
2205
  if (docLog.enabled) {
2140
2206
  docLog('Matched nodeRule: <%s>(%s)', node.nodeName, matches.selector || '*');
@@ -2150,7 +2216,7 @@ export class MLDocument extends MLParentNode {
2150
2216
  continue;
2151
2217
  }
2152
2218
  const globalRule = ruleset.rules[ruleName];
2153
- const mergedRule = globalRule != null ? mergeRule(globalRule, convertedRule) : convertedRule;
2219
+ const mergedRule = globalRule == null ? convertedRule : mergeRule(globalRule, convertedRule);
2154
2220
  ruleLog('↑ nodeRule (%s): %O', ruleName, mergedRule);
2155
2221
  ruleMapper.set(node, ruleName, {
2156
2222
  from: 'nodeRules',
@@ -2158,52 +2224,52 @@ export class MLDocument extends MLParentNode {
2158
2224
  rule: mergedRule,
2159
2225
  });
2160
2226
  }
2161
- });
2227
+ }
2162
2228
  // overwrite rule to child node
2163
2229
  if (selectorTarget && ruleset.childNodeRules.length > 0) {
2164
2230
  const descendants = [];
2165
- const children = Array.from(selectorTarget.childNodes);
2231
+ const children = [...selectorTarget.childNodes];
2166
2232
  syncWalk(children, childNode => {
2167
2233
  descendants.push(childNode);
2168
2234
  });
2169
- ruleset.childNodeRules.forEach(nodeRule => {
2235
+ for (const nodeRule of ruleset.childNodeRules) {
2170
2236
  if (!nodeRule.rules) {
2171
- return;
2237
+ continue;
2172
2238
  }
2173
2239
  const nodeRuleRules = nodeRule.rules;
2174
2240
  const selector = nodeRule.selector ?? nodeRule.regexSelector;
2175
2241
  if (selector == null) {
2176
- return;
2242
+ continue;
2177
2243
  }
2178
2244
  const matches = matchSelector(selectorTarget, selector);
2179
2245
  if (!matches.matched) {
2180
- return;
2246
+ continue;
2181
2247
  }
2182
2248
  if (docLog.enabled) {
2183
2249
  docLog('Matched childNodeRule: <%s>(%s), inheritance: %o', selectorTarget.nodeName, matches.selector || '*', !!nodeRule.inheritance);
2184
2250
  }
2185
2251
  const targetDescendants = nodeRule.inheritance ? descendants : children;
2186
- Object.keys(nodeRuleRules).forEach(ruleName => {
2252
+ for (const ruleName of Object.keys(nodeRuleRules)) {
2187
2253
  const rule = nodeRuleRules[ruleName];
2188
2254
  if (rule == null) {
2189
- return;
2255
+ continue;
2190
2256
  }
2191
2257
  const convertedRule = exchangeValueOnRule(rule, matches.data ?? {});
2192
2258
  if (convertedRule === undefined) {
2193
- return;
2259
+ continue;
2194
2260
  }
2195
2261
  const globalRule = ruleset.rules[ruleName];
2196
- const mergedRule = globalRule != null ? mergeRule(globalRule, convertedRule) : convertedRule;
2262
+ const mergedRule = globalRule == null ? convertedRule : mergeRule(globalRule, convertedRule);
2197
2263
  ruleLog('↑ childNodeRule (%s): %O', ruleName, mergedRule);
2198
- targetDescendants.forEach(descendant => {
2264
+ for (const descendant of targetDescendants) {
2199
2265
  ruleMapper.set(descendant, ruleName, {
2200
2266
  from: 'childNodeRules',
2201
2267
  specificity: matches.specificity,
2202
2268
  rule: mergedRule,
2203
2269
  });
2204
- });
2205
- });
2206
- });
2270
+ }
2271
+ }
2272
+ }
2207
2273
  }
2208
2274
  }
2209
2275
  ruleMapper.apply();
@@ -1,7 +1,17 @@
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 _MLDomTokenList_origin, _MLDomTokenList_ownerAttrs, _MLDomTokenList_set;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
- import { getCol, getLine } from '@markuplint/parser-utils';
4
- import UnexpectedCallError from './unexpected-call-error.js';
13
+ import { getCol, getLine } from '@markuplint/parser-utils/location';
14
+ import { UnexpectedCallError } from './unexpected-call-error.js';
5
15
  export class MLDomTokenList extends Array {
6
16
  constructor(tokens,
7
17
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
@@ -40,7 +50,7 @@ export class MLDomTokenList extends Array {
40
50
  */
41
51
  allTokens() {
42
52
  let offset = 0;
43
- const tokens = Array.from(this);
53
+ const tokens = [...this];
44
54
  const locs = [];
45
55
  while (tokens.length > 0) {
46
56
  const token = tokens.shift();
@@ -104,7 +114,7 @@ export class MLDomTokenList extends Array {
104
114
  throw new UnexpectedCallError('Not supported "toggle" method');
105
115
  }
106
116
  _pick(token, _offset = 0) {
107
- token = token.trim().split(/\s+/g)[0] ?? '';
117
+ token = token.trim().split(/\s+/)[0] ?? '';
108
118
  if (!token) {
109
119
  return null;
110
120
  }
@@ -0,0 +1,20 @@
1
+ import type { MLDocument } from './document.js';
2
+ import type { MLElement } from './element.js';
3
+ import type { MLASTElementCloseTag } from '@markuplint/ml-ast';
4
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
5
+ import { MLNode } from './node.js';
6
+ export declare class MLElementCloseTag<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTElementCloseTag> {
7
+ readonly pair: MLElement<T, O>;
8
+ constructor(astNode: MLASTElementCloseTag, document: MLDocument<T, O>, pair: MLElement<T, O>);
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(): string;
15
+ /**
16
+ * @implements `@markuplint/ml-core` API: `MLElement`
17
+ */
18
+ get rawName(): string;
19
+ toString(fixed?: boolean): string;
20
+ }
@@ -0,0 +1,39 @@
1
+ import { MLNode } from './node.js';
2
+ export class MLElementCloseTag extends MLNode {
3
+ constructor(astNode,
4
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
5
+ document,
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ pair) {
8
+ super(astNode, document);
9
+ this.pair = pair;
10
+ }
11
+ /**
12
+ * Returns a string appropriate for the type of node as `MLBlock`
13
+ *
14
+ * @implements `@markuplint/ml-core` API: `MLBlock`
15
+ */
16
+ get nodeName() {
17
+ return this.pair.nodeName;
18
+ }
19
+ /**
20
+ * @implements `@markuplint/ml-core` API: `MLElement`
21
+ */
22
+ get rawName() {
23
+ return this._astToken.nodeName;
24
+ }
25
+ toString(fixed = false) {
26
+ if (!fixed) {
27
+ return this.raw;
28
+ }
29
+ if (this.pair.isOmitted) {
30
+ return this.raw;
31
+ }
32
+ return [
33
+ this.pair.tagOpenChar,
34
+ this.pair.tagOpenChar === '' ? '' : '/',
35
+ this.pair.fixedNodeName === this.pair.rawName ? this.rawName : this.pair.fixedNodeName,
36
+ this.pair.tagCloseChar,
37
+ ].join('');
38
+ }
39
+ }
@@ -8,13 +8,19 @@ import type { ARIAVersion } from '@markuplint/ml-spec';
8
8
  import { MLToken } from '../token/token.js';
9
9
  import { MLAttr } from './attr.js';
10
10
  import { MLDomTokenList } from './dom-token-list.js';
11
+ import { MLElementCloseTag } from './element-close-tag.js';
11
12
  import { MLParentNode } from './parent-node.js';
12
13
  export declare class MLElement<T extends RuleConfigValue, O extends PlainData = undefined> extends MLParentNode<T, O, MLASTElement> implements Element, HTMLOrSVGElement, HTMLElement {
13
14
  #private;
14
- readonly closeTag: MLToken | null;
15
+ readonly closeTag: MLElementCloseTag<T, O> | null;
16
+ /**
17
+ * Element type
18
+ *
19
+ * - `html`: From native HTML Standard
20
+ * - `web-component`: As the Web Component according to HTML Standard
21
+ * - `authored`: Authored element (JSX Element etc.) through the view framework or the template engine.
22
+ */
15
23
  readonly elementType: ElementType;
16
- readonly endSpace: MLToken | null;
17
- readonly hasSpreadAttr: boolean;
18
24
  readonly isForeignElement: boolean;
19
25
  readonly isOmitted: boolean;
20
26
  readonly namespaceURI: NamespaceURI;
@@ -24,6 +30,8 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
24
30
  readonly ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
25
31
  pretenderContext: PretenderContext<MLElement<T, O>, T, O> | null;
26
32
  readonly selfClosingSolidus: MLToken | null;
33
+ readonly tagCloseChar: string;
34
+ readonly tagOpenChar: string;
27
35
  constructor(astNode: MLASTElement, document: MLDocument<T, O>);
28
36
  /**
29
37
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -469,6 +477,7 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
469
477
  * @implements `@markuplint/ml-core` API: `MLElement`
470
478
  */
471
479
  get fixedNodeName(): string;
480
+ get hasSpreadAttr(): boolean;
472
481
  /**
473
482
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
474
483
  *
@@ -1165,6 +1174,7 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1165
1174
  * @implements DOM API: `Element`
1166
1175
  */
1167
1176
  get onscroll(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
1177
+ get onscrollend(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
1168
1178
  /**
1169
1179
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1170
1180
  *
@@ -1373,6 +1383,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1373
1383
  * @see https://www.w3.org/TR/css-shadow-parts-1/#idl
1374
1384
  */
1375
1385
  get part(): DOMTokenList;
1386
+ /**
1387
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1388
+ *
1389
+ * @unsupported
1390
+ * @implements DOM API: `Element`
1391
+ * @see https://html.spec.whatwg.org/multipage/popover.html#dom-popover
1392
+ */
1393
+ get popover(): string | null;
1376
1394
  /**
1377
1395
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1378
1396
  *
@@ -1389,7 +1407,6 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1389
1407
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A1
1390
1408
  */
1391
1409
  get previousElementSibling(): MLElement<T, O> | null;
1392
- get raw(): string;
1393
1410
  /**
1394
1411
  * @implements `@markuplint/ml-core` API: `MLElement`
1395
1412
  */
@@ -1521,6 +1538,10 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1521
1538
  * @see https://www.w3.org/TR/web-animations-1/#dom-animatable-animate
1522
1539
  */
1523
1540
  animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation;
1541
+ /**
1542
+ * @see https://html.spec.whatwg.org/multipage/scripting.html#dom-slot-assignednodes
1543
+ */
1544
+ assignedNodes(): never[];
1524
1545
  /**
1525
1546
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1526
1547
  *
@@ -1720,6 +1741,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1720
1741
  * @see https://www.w3.org/TR/pointerevents2/#dom-element-haspointercapture
1721
1742
  */
1722
1743
  hasPointerCapture(pointerId: number): boolean;
1744
+ /**
1745
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1746
+ *
1747
+ * @unsupported
1748
+ * @implements DOM API: `Element`
1749
+ * @see https://html.spec.whatwg.org/multipage/popover.html#dom-hidepopover
1750
+ */
1751
+ hidePopover(): void;
1723
1752
  /**
1724
1753
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1725
1754
  *
@@ -1760,7 +1789,7 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1760
1789
  /**
1761
1790
  * Pretenders Initialization
1762
1791
  */
1763
- pretending(pretenders: readonly Pretender[]): void;
1792
+ pretending(pretenders?: readonly Pretender[]): void;
1764
1793
  /**
1765
1794
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1766
1795
  *
@@ -1889,6 +1918,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1889
1918
  * @see https://www.w3.org/TR/pointerevents2/#idl-def-element-setpointercapture-pointerid
1890
1919
  */
1891
1920
  setPointerCapture(pointerId: number): void;
1921
+ /**
1922
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1923
+ *
1924
+ * @unsupported
1925
+ * @implements DOM API: `Element`
1926
+ * @see https://html.spec.whatwg.org/multipage/popover.html#dom-showpopover
1927
+ */
1928
+ showPopover(): void;
1892
1929
  /**
1893
1930
  * @implements `@markuplint/ml-core` API: `MLElement`
1894
1931
  */
@@ -1896,7 +1933,7 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1896
1933
  /**
1897
1934
  * @implements `@markuplint/ml-core` API: `MLElement`
1898
1935
  */
1899
- toString(): string;
1936
+ toString(fixed?: boolean): string;
1900
1937
  /**
1901
1938
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1902
1939
  *
@@ -1905,6 +1942,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1905
1942
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
1906
1943
  */
1907
1944
  toggleAttribute(qualifiedName: string, force?: boolean): boolean;
1945
+ /**
1946
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1947
+ *
1948
+ * @unsupported
1949
+ * @implements DOM API: `Element`
1950
+ * @see https://html.spec.whatwg.org/multipage/popover.html#dom-togglepopover
1951
+ */
1952
+ togglePopover(force?: boolean): void;
1908
1953
  /**
1909
1954
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1910
1955
  *