@markuplint/ml-spec 3.14.0 → 4.0.0-alpha.10

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 (92) hide show
  1. package/LICENSE +1 -1
  2. package/lib/constant/aria-version.d.ts +2 -2
  3. package/lib/constant/aria-version.js +2 -5
  4. package/lib/dom-traverse/accname-computation.js +4 -7
  5. package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
  6. package/lib/dom-traverse/get-attr-specs.js +3 -7
  7. package/lib/dom-traverse/get-computed-aria-props.d.ts +6 -6
  8. package/lib/dom-traverse/get-computed-aria-props.js +13 -18
  9. package/lib/dom-traverse/get-computed-role.d.ts +2 -7
  10. package/lib/dom-traverse/get-computed-role.js +33 -39
  11. package/lib/dom-traverse/get-content-model.d.ts +2 -27
  12. package/lib/dom-traverse/get-content-model.js +5 -10
  13. package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
  14. package/lib/dom-traverse/get-explicit-role.js +9 -14
  15. package/lib/dom-traverse/get-implicit-role.d.ts +2 -6
  16. package/lib/dom-traverse/get-implicit-role.js +8 -13
  17. package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +5 -11
  18. package/lib/dom-traverse/get-non-presentational-ancestor.js +5 -10
  19. package/lib/dom-traverse/get-permitted-roles.d.ts +4 -8
  20. package/lib/dom-traverse/get-permitted-roles.js +3 -7
  21. package/lib/dom-traverse/get-spec.d.ts +2 -5
  22. package/lib/dom-traverse/get-spec.js +3 -7
  23. package/lib/dom-traverse/has-required-owned-elements.d.ts +2 -8
  24. package/lib/dom-traverse/has-required-owned-elements.js +13 -20
  25. package/lib/dom-traverse/is-exposed.d.ts +1 -1
  26. package/lib/dom-traverse/is-exposed.js +17 -24
  27. package/lib/dom-traverse/matches-context-role.d.ts +2 -7
  28. package/lib/dom-traverse/matches-context-role.js +5 -9
  29. package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
  30. package/lib/dom-traverse/may-be-focusable.js +3 -7
  31. package/lib/index.d.ts +28 -28
  32. package/lib/index.js +28 -33
  33. package/lib/specs/aria-specs.d.ts +5 -8
  34. package/lib/specs/aria-specs.js +1 -5
  35. package/lib/specs/content-model-category-to-tag-names.d.ts +3 -6
  36. package/lib/specs/content-model-category-to-tag-names.js +1 -5
  37. package/lib/specs/get-aria.d.ts +3 -9
  38. package/lib/specs/get-aria.js +11 -17
  39. package/lib/specs/get-attr-specs.d.ts +4 -8
  40. package/lib/specs/get-attr-specs.js +6 -11
  41. package/lib/specs/get-implicit-role.d.ts +2 -8
  42. package/lib/specs/get-implicit-role.js +3 -7
  43. package/lib/specs/get-permitted-roles.d.ts +4 -10
  44. package/lib/specs/get-permitted-roles.js +14 -17
  45. package/lib/specs/get-role-spec.d.ts +4 -11
  46. package/lib/specs/get-role-spec.js +10 -14
  47. package/lib/specs/get-selectors-by-content-model-category.d.ts +2 -2
  48. package/lib/specs/get-selectors-by-content-model-category.js +2 -6
  49. package/lib/specs/get-spec-by-tag-name.d.ts +2 -6
  50. package/lib/specs/get-spec-by-tag-name.js +4 -9
  51. package/lib/specs/is-nothing-content-model.js +3 -7
  52. package/lib/specs/is-palpable-elements.d.ts +5 -9
  53. package/lib/specs/is-palpable-elements.js +5 -10
  54. package/lib/specs/is-presentational.js +1 -5
  55. package/lib/specs/is-void-element.d.ts +3 -1
  56. package/lib/specs/is-void-element.js +4 -10
  57. package/lib/specs/resolve-version.d.ts +3 -6
  58. package/lib/specs/resolve-version.js +7 -12
  59. package/lib/specs/schema-to-spec.d.ts +4 -4
  60. package/lib/specs/schema-to-spec.js +20 -25
  61. package/lib/types/aria.d.ts +133 -147
  62. package/lib/types/aria.js +1 -2
  63. package/lib/types/attributes.d.ts +110 -1504
  64. package/lib/types/attributes.js +1 -2
  65. package/lib/types/index.d.ts +149 -177
  66. package/lib/types/index.js +1 -2
  67. package/lib/types/permitted-structures.d.ts +35 -74
  68. package/lib/types/permitted-structures.js +1 -2
  69. package/lib/utils/get-ns.js +1 -5
  70. package/lib/utils/merge-array.d.ts +4 -9
  71. package/lib/utils/merge-array.js +2 -6
  72. package/lib/utils/resolve-namespace.d.ts +4 -4
  73. package/lib/utils/resolve-namespace.js +4 -9
  74. package/lib/utils/{validateAriaVersion.d.ts → validate-aria-version.d.ts} +1 -1
  75. package/lib/utils/validate-aria-version.js +4 -0
  76. package/package.json +20 -14
  77. package/lib/utils/validateAriaVersion.js +0 -8
  78. package/test/dom-traverse/accname-computation.spec.js +0 -69
  79. package/test/dom-traverse/get-computed-aria-props.spec.js +0 -758
  80. package/test/dom-traverse/get-computed-role.spec.js +0 -315
  81. package/test/dom-traverse/get-implicit-role.spec.js +0 -40
  82. package/test/dom-traverse/has-required-owned-elements.spec.js +0 -34
  83. package/test/dom-traverse/is-exposed.spec.js +0 -70
  84. package/test/dom-traverse/matches-context-role.spec.js +0 -60
  85. package/test/specs/get-attr-specs.spec.js +0 -41
  86. package/test/specs/get-implicit-role.spec.js +0 -79
  87. package/test/specs/get-permitted-roles.spec.js +0 -418
  88. package/test/specs/get-role-spec.spec.js +0 -67
  89. package/test/specs/get-spec-by-tag-name.spec.js +0 -68
  90. package/test/specs/resolve-version.spec.js +0 -34
  91. package/test/specs/schema-to-spec.spec.js +0 -61
  92. package/test/utils/resolve-namespace.spec.js +0 -37
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRequiredOwnedElement = exports.hasRequiredOwnedElement = void 0;
4
- const is_presentational_1 = require("../specs/is-presentational");
5
- const get_computed_role_1 = require("./get-computed-role");
6
- const get_explicit_role_1 = require("./get-explicit-role");
7
- const get_implicit_role_1 = require("./get-implicit-role");
8
- function hasRequiredOwnedElement(
1
+ import { isPresentational } from '../specs/is-presentational.js';
2
+ import { getComputedRole } from './get-computed-role.js';
3
+ import { getExplicitRole } from './get-explicit-role.js';
4
+ import { getImplicitRole } from './get-implicit-role.js';
5
+ export function hasRequiredOwnedElement(
9
6
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
10
7
  el, specs, version) {
11
8
  /**
@@ -20,7 +17,7 @@ el, specs, version) {
20
17
  /**
21
18
  * Otherwise, traverses descendants to find owned elements.
22
19
  */
23
- const computed = (0, get_computed_role_1.getComputedRole)(specs, el, version);
20
+ const computed = getComputedRole(specs, el, version);
24
21
  if (!computed.role || computed.role.requiredOwnedElements.length === 0) {
25
22
  return true;
26
23
  }
@@ -33,26 +30,23 @@ el, specs, version) {
33
30
  }
34
31
  return false;
35
32
  }
36
- exports.hasRequiredOwnedElement = hasRequiredOwnedElement;
37
- function isRequiredOwnedElement(
33
+ export function isRequiredOwnedElement(
38
34
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
39
35
  el, role, query, specs, version) {
40
- var _a;
41
36
  const [baseRole, owningRole] = query.split(' > ');
42
- if ((role === null || role === void 0 ? void 0 : role.name) !== baseRole) {
37
+ if (role?.name !== baseRole) {
43
38
  return false;
44
39
  }
45
40
  if (!owningRole) {
46
41
  return true;
47
42
  }
48
43
  for (const owning of getClosestNonPresentationalDescendants(el, specs, version)) {
49
- if (((_a = owning.role) === null || _a === void 0 ? void 0 : _a.name) === owningRole) {
44
+ if (owning.role?.name === owningRole) {
50
45
  return true;
51
46
  }
52
47
  }
53
48
  return false;
54
49
  }
55
- exports.isRequiredOwnedElement = isRequiredOwnedElement;
56
50
  /**
57
51
  * Gets the list of closest non-presentational descendants.
58
52
  * ⚠ THE SPECIFICATION HAS AN ISSUE
@@ -71,13 +65,12 @@ exports.isRequiredOwnedElement = isRequiredOwnedElement;
71
65
  function getClosestNonPresentationalDescendants(
72
66
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
73
67
  el, specs, version) {
74
- var _a;
75
68
  const owned = [];
76
- for (const child of Array.from(el.children)) {
77
- const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, child, version);
78
- const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, child, version);
69
+ for (const child of el.children) {
70
+ const implicitRole = getImplicitRole(specs, child, version);
71
+ const explicitRole = getExplicitRole(specs, child, version);
79
72
  const computed = explicitRole.role ? explicitRole : implicitRole;
80
- if ((0, is_presentational_1.isPresentational)((_a = computed.role) === null || _a === void 0 ? void 0 : _a.name)) {
73
+ if (isPresentational(computed.role?.name)) {
81
74
  owned.push(...getClosestNonPresentationalDescendants(child, specs, version));
82
75
  continue;
83
76
  }
@@ -1,4 +1,4 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
2
  /**
3
3
  * Detect including/excluding from the Accessibility Tree
4
4
  *
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isExposed = void 0;
4
- const aria_specs_1 = require("../specs/aria-specs");
5
- const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
6
- const is_presentational_1 = require("../specs/is-presentational");
7
- const resolve_namespace_1 = require("../utils/resolve-namespace");
8
- const get_computed_role_1 = require("./get-computed-role");
1
+ import { ariaSpecs } from '../specs/aria-specs.js';
2
+ import { getSpecByTagName } from '../specs/get-spec-by-tag-name.js';
3
+ import { isPresentational } from '../specs/is-presentational.js';
4
+ import { resolveNamespace } from '../utils/resolve-namespace.js';
5
+ import { getComputedRole } from './get-computed-role.js';
9
6
  /**
10
7
  * Detect including/excluding from the Accessibility Tree
11
8
  *
@@ -15,7 +12,7 @@ const get_computed_role_1 = require("./get-computed-role");
15
12
  * @param el
16
13
  * @param version
17
14
  */
18
- function isExposed(
15
+ export function isExposed(
19
16
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
20
17
  el, specs, version) {
21
18
  // According to WAI-ARIA
@@ -23,8 +20,8 @@ el, specs, version) {
23
20
  return false;
24
21
  }
25
22
  // Return true if the element is unknown, deprecated, or obsolete.
26
- const { localName, namespace } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
27
- const spec = (0, get_spec_by_tag_name_1.getSpecByTagName)(specs.specs, localName, namespace);
23
+ const { localName, namespace } = resolveNamespace(el.localName, el.namespaceURI);
24
+ const spec = getSpecByTagName(specs.specs, localName, namespace);
28
25
  if (!spec || spec.deprecated || spec.obsolete != null) {
29
26
  return true;
30
27
  }
@@ -44,7 +41,6 @@ el, specs, version) {
44
41
  // Default
45
42
  return true;
46
43
  }
47
- exports.isExposed = isExposed;
48
44
  /**
49
45
  * Excluding Elements from the Accessibility Tree
50
46
  *
@@ -57,7 +53,6 @@ exports.isExposed = isExposed;
57
53
  function isExcluding(
58
54
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
59
55
  el, specs, version) {
60
- var _a;
61
56
  /**
62
57
  * The following elements are not exposed via the accessibility API and
63
58
  * user agents MUST NOT include them in the accessibility tree:
@@ -82,7 +77,7 @@ el, specs, version) {
82
77
  * These exceptions and conditions are documented in the presentation (role)
83
78
  * section.
84
79
  */
85
- if ((0, is_presentational_1.isPresentational)(((_a = el.getAttribute('role')) !== null && _a !== void 0 ? _a : '').split(/\s+/)[0])) {
80
+ if (isPresentational((el.getAttribute('role') ?? '').split(/\s+/)[0])) {
86
81
  return true;
87
82
  }
88
83
  /**
@@ -113,8 +108,8 @@ el, specs, version) {
113
108
  {
114
109
  let currentEl = el.parentElement;
115
110
  while (currentEl) {
116
- const { role } = (0, get_computed_role_1.getComputedRole)(specs, currentEl, version);
117
- if (role === null || role === void 0 ? void 0 : role.childrenPresentational) {
111
+ const { role } = getComputedRole(specs, currentEl, version);
112
+ if (role?.childrenPresentational) {
118
113
  return true;
119
114
  }
120
115
  currentEl = currentEl.parentElement;
@@ -163,14 +158,14 @@ el, specs, version) {
163
158
  * additional guidance on aria-hidden.)
164
159
  */
165
160
  if (el.getAttribute('aria-hidden') !== 'true') {
166
- const globalAria = (0, aria_specs_1.ariaSpecs)(specs, version).props.filter(prop => prop.isGlobal);
167
- const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
161
+ const globalAria = ariaSpecs(specs, version).props.filter(prop => prop.isGlobal);
162
+ const { role } = getComputedRole(specs, el, version);
168
163
  // Has an explicit role
169
164
  if (role && !role.isImplicit) {
170
165
  results.push(true);
171
166
  }
172
167
  // Has a global WAI-ARIA attribute
173
- for (const attr of Array.from(el.attributes)) {
168
+ for (const attr of el.attributes) {
174
169
  if (globalAria.some(aria => aria.name === attr.localName)) {
175
170
  results.push(true);
176
171
  break;
@@ -193,13 +188,12 @@ el) {
193
188
  return false;
194
189
  }
195
190
  // TODO: Improve accuracy
196
- return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
191
+ return /display\s*:\s*none|visibility\s*:\s*hidden/i.test(style);
197
192
  }
198
193
  function isExposedElement(
199
194
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
200
195
  el, specs) {
201
- var _a;
202
- const svgRenderedConditions = (_a = specs.def['#contentModels']['#SVGRenderable']) === null || _a === void 0 ? void 0 : _a.join(',');
196
+ const svgRenderedConditions = specs.def['#contentModels']['#SVGRenderable']?.join(',');
203
197
  if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
204
198
  return true;
205
199
  }
@@ -208,8 +202,7 @@ el, specs) {
208
202
  function isNotMetaOrHiddenHTMLElement(
209
203
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
210
204
  el, specs) {
211
- var _a;
212
- const metadataConditions = (_a = specs.def['#contentModels']['#metadata']) === null || _a === void 0 ? void 0 : _a.join(',');
205
+ const metadataConditions = specs.def['#contentModels']['#metadata']?.join(',');
213
206
  if (metadataConditions && el.matches(metadataConditions)) {
214
207
  return false;
215
208
  }
@@ -1,7 +1,2 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function matchesContextRole(
3
- conditions: readonly string[],
4
- ownedEl: Element,
5
- specs: MLMLSpec,
6
- version: ARIAVersion,
7
- ): boolean;
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
+ export declare function matchesContextRole(conditions: readonly string[], ownedEl: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
@@ -1,24 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.matchesContextRole = void 0;
4
- const get_computed_role_1 = require("./get-computed-role");
5
- function matchesContextRole(conditions,
1
+ import { getComputedRole } from './get-computed-role.js';
2
+ export function matchesContextRole(conditions,
6
3
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
4
  ownedEl, specs, version) {
8
5
  return conditions.some(condition => matchesCondition(condition, ownedEl.parentElement, specs, version));
9
6
  }
10
- exports.matchesContextRole = matchesContextRole;
11
7
  function matchesCondition(condition,
12
8
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
13
9
  parentEl, specs, version) {
14
- const conditions = condition.split(/\s+>\s+/g).reverse();
10
+ const conditions = condition.split(/\s+>\s+/).reverse();
15
11
  while (conditions.length > 0) {
16
12
  if (!parentEl) {
17
13
  return false;
18
14
  }
19
15
  const condition = conditions.shift();
20
- const parentRole = (0, get_computed_role_1.getComputedRole)(specs, parentEl, version, true).role;
21
- if (condition !== (parentRole === null || parentRole === void 0 ? void 0 : parentRole.name)) {
16
+ const parentRole = getComputedRole(specs, parentEl, version, true).role;
17
+ if (condition !== parentRole?.name) {
22
18
  return false;
23
19
  }
24
20
  parentEl = parentEl.parentElement;
@@ -1,2 +1,2 @@
1
- import type { MLMLSpec } from '../types';
1
+ import type { MLMLSpec } from '../types/index.js';
2
2
  export declare function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mayBeFocusable = void 0;
4
- const get_selectors_by_content_model_category_1 = require("../specs/get-selectors-by-content-model-category");
5
- function mayBeFocusable(
1
+ import { getSelectorsByContentModelCategory } from '../specs/get-selectors-by-content-model-category.js';
2
+ export function mayBeFocusable(
6
3
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
4
  el, specs) {
8
5
  return [
@@ -11,7 +8,7 @@ el, specs) {
11
8
  *
12
9
  * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
13
10
  */
14
- ...(0, get_selectors_by_content_model_category_1.getSelectorsByContentModelCategory)(specs, '#interactive'),
11
+ ...getSelectorsByContentModelCategory(specs, '#interactive'),
15
12
  /**
16
13
  * Interaction
17
14
  *
@@ -21,4 +18,3 @@ el, specs) {
21
18
  '[contenteditable]:not([contenteditable="false" i])',
22
19
  ].some(selector => el.matches(selector));
23
20
  }
24
- exports.mayBeFocusable = mayBeFocusable;
package/lib/index.d.ts CHANGED
@@ -1,28 +1,28 @@
1
- export { getAttrSpecs as getAttrSpecsByNames } from './specs/get-attr-specs';
2
- export * from './constant/aria-version';
3
- export * from './dom-traverse/accname-computation';
4
- export * from './dom-traverse/get-attr-specs';
5
- export * from './dom-traverse/get-computed-aria-props';
6
- export * from './dom-traverse/get-computed-role';
7
- export * from './dom-traverse/get-content-model';
8
- export * from './dom-traverse/get-implicit-role';
9
- export * from './dom-traverse/get-permitted-roles';
10
- export * from './dom-traverse/get-spec';
11
- export * from './dom-traverse/has-required-owned-elements';
12
- export * from './dom-traverse/is-exposed';
13
- export * from './dom-traverse/may-be-focusable';
14
- export * from './specs/aria-specs';
15
- export * from './specs/content-model-category-to-tag-names';
16
- export * from './specs/get-aria';
17
- export * from './specs/get-role-spec';
18
- export * from './specs/get-spec-by-tag-name';
19
- export * from './specs/is-nothing-content-model';
20
- export * from './specs/is-palpable-elements';
21
- export * from './specs/is-void-element';
22
- export * from './specs/schema-to-spec';
23
- export * from './types';
24
- export * from './types/aria';
25
- export * from './types/attributes';
26
- export * from './types/permitted-structures';
27
- export * from './utils/resolve-namespace';
28
- export * from './utils/validateAriaVersion';
1
+ export { getAttrSpecs as getAttrSpecsByNames } from './specs/get-attr-specs.js';
2
+ export * from './constant/aria-version.js';
3
+ export * from './dom-traverse/accname-computation.js';
4
+ export * from './dom-traverse/get-attr-specs.js';
5
+ export * from './dom-traverse/get-computed-aria-props.js';
6
+ export * from './dom-traverse/get-computed-role.js';
7
+ export * from './dom-traverse/get-content-model.js';
8
+ export * from './dom-traverse/get-implicit-role.js';
9
+ export * from './dom-traverse/get-permitted-roles.js';
10
+ export * from './dom-traverse/get-spec.js';
11
+ export * from './dom-traverse/has-required-owned-elements.js';
12
+ export * from './dom-traverse/is-exposed.js';
13
+ export * from './dom-traverse/may-be-focusable.js';
14
+ export * from './specs/aria-specs.js';
15
+ export * from './specs/content-model-category-to-tag-names.js';
16
+ export * from './specs/get-aria.js';
17
+ export * from './specs/get-role-spec.js';
18
+ export * from './specs/get-spec-by-tag-name.js';
19
+ export * from './specs/is-nothing-content-model.js';
20
+ export * from './specs/is-palpable-elements.js';
21
+ export * from './specs/is-void-element.js';
22
+ export * from './specs/schema-to-spec.js';
23
+ export * from './types/index.js';
24
+ export * from './types/aria.js';
25
+ export * from './types/attributes.js';
26
+ export * from './types/permitted-structures.js';
27
+ export * from './utils/resolve-namespace.js';
28
+ export * from './utils/validate-aria-version.js';
package/lib/index.js CHANGED
@@ -1,33 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAttrSpecsByNames = void 0;
4
- const tslib_1 = require("tslib");
5
- var get_attr_specs_1 = require("./specs/get-attr-specs");
6
- Object.defineProperty(exports, "getAttrSpecsByNames", { enumerable: true, get: function () { return get_attr_specs_1.getAttrSpecs; } });
7
- tslib_1.__exportStar(require("./constant/aria-version"), exports);
8
- tslib_1.__exportStar(require("./dom-traverse/accname-computation"), exports);
9
- tslib_1.__exportStar(require("./dom-traverse/get-attr-specs"), exports);
10
- tslib_1.__exportStar(require("./dom-traverse/get-computed-aria-props"), exports);
11
- tslib_1.__exportStar(require("./dom-traverse/get-computed-role"), exports);
12
- tslib_1.__exportStar(require("./dom-traverse/get-content-model"), exports);
13
- tslib_1.__exportStar(require("./dom-traverse/get-implicit-role"), exports);
14
- tslib_1.__exportStar(require("./dom-traverse/get-permitted-roles"), exports);
15
- tslib_1.__exportStar(require("./dom-traverse/get-spec"), exports);
16
- tslib_1.__exportStar(require("./dom-traverse/has-required-owned-elements"), exports);
17
- tslib_1.__exportStar(require("./dom-traverse/is-exposed"), exports);
18
- tslib_1.__exportStar(require("./dom-traverse/may-be-focusable"), exports);
19
- tslib_1.__exportStar(require("./specs/aria-specs"), exports);
20
- tslib_1.__exportStar(require("./specs/content-model-category-to-tag-names"), exports);
21
- tslib_1.__exportStar(require("./specs/get-aria"), exports);
22
- tslib_1.__exportStar(require("./specs/get-role-spec"), exports);
23
- tslib_1.__exportStar(require("./specs/get-spec-by-tag-name"), exports);
24
- tslib_1.__exportStar(require("./specs/is-nothing-content-model"), exports);
25
- tslib_1.__exportStar(require("./specs/is-palpable-elements"), exports);
26
- tslib_1.__exportStar(require("./specs/is-void-element"), exports);
27
- tslib_1.__exportStar(require("./specs/schema-to-spec"), exports);
28
- tslib_1.__exportStar(require("./types"), exports);
29
- tslib_1.__exportStar(require("./types/aria"), exports);
30
- tslib_1.__exportStar(require("./types/attributes"), exports);
31
- tslib_1.__exportStar(require("./types/permitted-structures"), exports);
32
- tslib_1.__exportStar(require("./utils/resolve-namespace"), exports);
33
- tslib_1.__exportStar(require("./utils/validateAriaVersion"), exports);
1
+ export { getAttrSpecs as getAttrSpecsByNames } from './specs/get-attr-specs.js';
2
+ export * from './constant/aria-version.js';
3
+ export * from './dom-traverse/accname-computation.js';
4
+ export * from './dom-traverse/get-attr-specs.js';
5
+ export * from './dom-traverse/get-computed-aria-props.js';
6
+ export * from './dom-traverse/get-computed-role.js';
7
+ export * from './dom-traverse/get-content-model.js';
8
+ export * from './dom-traverse/get-implicit-role.js';
9
+ export * from './dom-traverse/get-permitted-roles.js';
10
+ export * from './dom-traverse/get-spec.js';
11
+ export * from './dom-traverse/has-required-owned-elements.js';
12
+ export * from './dom-traverse/is-exposed.js';
13
+ export * from './dom-traverse/may-be-focusable.js';
14
+ export * from './specs/aria-specs.js';
15
+ export * from './specs/content-model-category-to-tag-names.js';
16
+ export * from './specs/get-aria.js';
17
+ export * from './specs/get-role-spec.js';
18
+ export * from './specs/get-spec-by-tag-name.js';
19
+ export * from './specs/is-nothing-content-model.js';
20
+ export * from './specs/is-palpable-elements.js';
21
+ export * from './specs/is-void-element.js';
22
+ export * from './specs/schema-to-spec.js';
23
+ export * from './types/index.js';
24
+ export * from './types/aria.js';
25
+ export * from './types/attributes.js';
26
+ export * from './types/permitted-structures.js';
27
+ export * from './utils/resolve-namespace.js';
28
+ export * from './utils/validate-aria-version.js';
@@ -1,9 +1,6 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function ariaSpecs(
3
- specs: MLMLSpec,
4
- version: ARIAVersion,
5
- ): {
6
- readonly roles: readonly import('../types').ARIARoleInSchema[];
7
- readonly graphicsRoles: readonly import('../types').ARIARoleInSchema[];
8
- readonly props: readonly import('../types').ARIAProperty[];
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
+ export declare function ariaSpecs(specs: MLMLSpec, version: ARIAVersion): {
3
+ readonly roles: readonly import("../types/index.js").ARIARoleInSchema[];
4
+ readonly graphicsRoles: readonly import("../types/index.js").ARIARoleInSchema[];
5
+ readonly props: readonly import("../types/index.js").ARIAProperty[];
9
6
  };
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ariaSpecs = void 0;
4
- function ariaSpecs(specs, version) {
1
+ export function ariaSpecs(specs, version) {
5
2
  const aria = specs.def['#aria'];
6
3
  return aria[version];
7
4
  }
8
- exports.ariaSpecs = ariaSpecs;
@@ -1,6 +1,3 @@
1
- import type { MLMLSpec } from '../types';
2
- import type { Category } from '../types/permitted-structures';
3
- export declare function contentModelCategoryToTagNames(
4
- contentModel: Category,
5
- def: MLMLSpec['def'],
6
- ): ReadonlyArray<string>;
1
+ import type { MLMLSpec } from '../types/index.js';
2
+ import type { Category } from '../types/permitted-structures.js';
3
+ export declare function contentModelCategoryToTagNames(contentModel: Category, def: MLMLSpec['def']): ReadonlyArray<string>;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contentModelCategoryToTagNames = void 0;
4
1
  const cache = new Map();
5
- function contentModelCategoryToTagNames(contentModel, def) {
2
+ export function contentModelCategoryToTagNames(contentModel, def) {
6
3
  const cached = cache.get(contentModel);
7
4
  if (cached) {
8
5
  return cached;
@@ -12,4 +9,3 @@ function contentModelCategoryToTagNames(contentModel, def) {
12
9
  cache.set(contentModel, sortedTag);
13
10
  return sortedTag;
14
11
  }
15
- exports.contentModelCategoryToTagNames = contentModelCategoryToTagNames;
@@ -1,10 +1,4 @@
1
- import type { ARIAVersion, Matches, MLMLSpec } from '../types';
2
- import type { ARIA } from '../types/aria';
1
+ import type { ARIA } from '../types/aria.js';
2
+ import type { ARIAVersion, Matches, MLMLSpec } from '../types/index.js';
3
3
  import type { ReadonlyDeep } from 'type-fest';
4
- export declare function getARIA(
5
- specs: MLMLSpec,
6
- localName: string,
7
- namespace: string | null,
8
- version: ARIAVersion,
9
- matches: Matches,
10
- ): Omit<ReadonlyDeep<ARIA>, ARIAVersion | 'conditions'> | null;
4
+ export declare function getARIA(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): Omit<ReadonlyDeep<ARIA>, ARIAVersion | 'conditions'> | null;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getARIA = void 0;
4
- const get_spec_by_tag_name_1 = require("./get-spec-by-tag-name");
5
- const resolve_version_1 = require("./resolve-version");
1
+ import { getSpecByTagName } from './get-spec-by-tag-name.js';
2
+ import { resolveVersion } from './resolve-version.js';
6
3
  const cache = new Map();
7
- function getARIA(specs, localName, namespace, version, matches) {
8
- var _a, _b, _c, _d, _e;
4
+ export function getARIA(specs, localName, namespace, version, matches) {
9
5
  const aria = getVersionResolvedARIA(specs, localName, namespace, version);
10
6
  if (!aria) {
11
7
  return null;
@@ -24,11 +20,11 @@ function getARIA(specs, localName, namespace, version, matches) {
24
20
  if (!condARIA) {
25
21
  continue;
26
22
  }
27
- implicitRole = (_a = condARIA.implicitRole) !== null && _a !== void 0 ? _a : implicitRole;
28
- permittedRoles = (_b = condARIA.permittedRoles) !== null && _b !== void 0 ? _b : permittedRoles;
29
- implicitProperties = (_c = condARIA.implicitProperties) !== null && _c !== void 0 ? _c : implicitProperties;
30
- properties = (_d = condARIA.properties) !== null && _d !== void 0 ? _d : properties;
31
- namingProhibited = (_e = condARIA.namingProhibited) !== null && _e !== void 0 ? _e : namingProhibited;
23
+ implicitRole = condARIA.implicitRole ?? implicitRole;
24
+ permittedRoles = condARIA.permittedRoles ?? permittedRoles;
25
+ implicitProperties = condARIA.implicitProperties ?? implicitProperties;
26
+ properties = condARIA.properties ?? properties;
27
+ namingProhibited = condARIA.namingProhibited ?? namingProhibited;
32
28
  }
33
29
  return {
34
30
  implicitRole,
@@ -38,20 +34,18 @@ function getARIA(specs, localName, namespace, version, matches) {
38
34
  namingProhibited,
39
35
  };
40
36
  }
41
- exports.getARIA = getARIA;
42
37
  function getVersionResolvedARIA(specs, localName, namespace, version) {
43
- var _a;
44
38
  const key = localName + namespace + version;
45
39
  let aria = cache.get(key);
46
40
  if (aria !== undefined) {
47
41
  return aria;
48
42
  }
49
- const spec = (_a = (0, get_spec_by_tag_name_1.getSpecByTagName)(specs.specs, localName, namespace)) === null || _a === void 0 ? void 0 : _a.aria;
43
+ const spec = getSpecByTagName(specs.specs, localName, namespace)?.aria;
50
44
  if (!spec) {
51
45
  cache.set(key, null);
52
46
  return null;
53
47
  }
54
- aria = (0, resolve_version_1.resolveVersion)(spec, version);
48
+ aria = resolveVersion(spec, version);
55
49
  if (aria.permittedRoles !== false) {
56
50
  aria = {
57
51
  ...aria,
@@ -73,5 +67,5 @@ function optimizePermittedRoles(permittedRoles) {
73
67
  if (unique.has('none')) {
74
68
  unique.add('presentation');
75
69
  }
76
- return Array.from(unique).sort();
70
+ return [...unique].sort();
77
71
  }
@@ -1,12 +1,8 @@
1
- import type { MLMLSpec, Attribute } from '../types';
1
+ import type { MLMLSpec, Attribute } from '../types/index.js';
2
2
  import type { NamespaceURI } from '@markuplint/ml-ast';
3
- export declare function getAttrSpecs(
4
- localName: string,
5
- namespace: NamespaceURI | null,
6
- schema: MLMLSpec,
7
- ): readonly Attribute[] | null;
3
+ export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): readonly Attribute[] | null;
8
4
  type HasName = {
9
- readonly name: string;
5
+ readonly name: string;
10
6
  };
11
- export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
7
+ export declare function nameCompare(a: HasName | string, b: HasName | string): 0 | 1 | -1;
12
8
  export {};
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nameCompare = exports.getAttrSpecs = void 0;
4
- const resolve_namespace_1 = require("../utils/resolve-namespace");
1
+ import { resolveNamespace } from '../utils/resolve-namespace.js';
5
2
  const cacheMap = new Map();
6
3
  const schemaCache = new WeakSet();
7
- function getAttrSpecs(localName, namespace, schema) {
4
+ export function getAttrSpecs(localName, namespace, schema) {
8
5
  if (!schemaCache.has(schema)) {
9
6
  cacheMap.clear();
10
7
  }
11
- const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace !== null && namespace !== void 0 ? namespace : undefined);
8
+ const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined);
12
9
  const cache = cacheMap.get(localNameWithNS);
13
10
  if (cache !== undefined) {
14
11
  return cache;
@@ -40,13 +37,13 @@ function getAttrSpecs(localName, namespace, schema) {
40
37
  if (!global) {
41
38
  continue;
42
39
  }
43
- catAttrs.forEach(selectedName => {
40
+ for (const selectedName of catAttrs) {
44
41
  const selected = global[selectedName];
45
42
  attrs[selectedName] = {
46
43
  ...attrs[selectedName],
47
44
  ...selected,
48
45
  };
49
- });
46
+ }
50
47
  continue;
51
48
  }
52
49
  }
@@ -70,8 +67,7 @@ function getAttrSpecs(localName, namespace, schema) {
70
67
  cacheMap.set(localNameWithNS, attrList);
71
68
  return attrList;
72
69
  }
73
- exports.getAttrSpecs = getAttrSpecs;
74
- function nameCompare(a, b) {
70
+ export function nameCompare(a, b) {
75
71
  const nameA = typeof a === 'string' ? a : a.name.toUpperCase();
76
72
  const nameB = typeof b === 'string' ? b : b.name.toUpperCase();
77
73
  if (nameA < nameB) {
@@ -82,4 +78,3 @@ function nameCompare(a, b) {
82
78
  }
83
79
  return 0;
84
80
  }
85
- exports.nameCompare = nameCompare;
@@ -1,8 +1,2 @@
1
- import type { ARIAVersion, Matches, MLMLSpec } from '../types';
2
- export declare function getImplicitRole(
3
- specs: MLMLSpec,
4
- localName: string,
5
- namespace: string | null,
6
- version: ARIAVersion,
7
- matches: Matches,
8
- ): import('..').ImplicitRole;
1
+ import type { ARIAVersion, Matches, MLMLSpec } from '../types/index.js';
2
+ export declare function getImplicitRole(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): import("../index.js").ImplicitRole;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImplicitRole = void 0;
4
- const get_aria_1 = require("./get-aria");
5
- function getImplicitRole(specs, localName, namespace, version, matches) {
6
- const aria = (0, get_aria_1.getARIA)(specs, localName, namespace, version, matches);
1
+ import { getARIA } from './get-aria.js';
2
+ export function getImplicitRole(specs, localName, namespace, version, matches) {
3
+ const aria = getARIA(specs, localName, namespace, version, matches);
7
4
  if (!aria) {
8
5
  return false;
9
6
  }
10
7
  return aria.implicitRole;
11
8
  }
12
- exports.getImplicitRole = getImplicitRole;