@markuplint/ml-spec 3.12.0 → 4.0.0-alpha.2

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 (83) hide show
  1. package/lib/constant/aria-version.js +2 -5
  2. package/lib/dom-traverse/accname-computation.js +4 -7
  3. package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
  4. package/lib/dom-traverse/get-attr-specs.js +3 -7
  5. package/lib/dom-traverse/get-computed-aria-props.d.ts +1 -1
  6. package/lib/dom-traverse/get-computed-aria-props.js +7 -12
  7. package/lib/dom-traverse/get-computed-role.d.ts +1 -1
  8. package/lib/dom-traverse/get-computed-role.js +28 -32
  9. package/lib/dom-traverse/get-content-model.d.ts +2 -2
  10. package/lib/dom-traverse/get-content-model.js +5 -10
  11. package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
  12. package/lib/dom-traverse/get-explicit-role.js +9 -14
  13. package/lib/dom-traverse/get-implicit-role.d.ts +2 -2
  14. package/lib/dom-traverse/get-implicit-role.js +8 -13
  15. package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
  16. package/lib/dom-traverse/get-non-presentational-ancestor.js +5 -10
  17. package/lib/dom-traverse/get-permitted-roles.d.ts +1 -1
  18. package/lib/dom-traverse/get-permitted-roles.js +3 -7
  19. package/lib/dom-traverse/get-spec.d.ts +1 -1
  20. package/lib/dom-traverse/get-spec.js +3 -7
  21. package/lib/dom-traverse/has-required-owned-elements.d.ts +1 -1
  22. package/lib/dom-traverse/has-required-owned-elements.js +12 -19
  23. package/lib/dom-traverse/is-exposed.d.ts +1 -1
  24. package/lib/dom-traverse/is-exposed.js +15 -22
  25. package/lib/dom-traverse/matches-context-role.d.ts +1 -1
  26. package/lib/dom-traverse/matches-context-role.js +4 -8
  27. package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
  28. package/lib/dom-traverse/may-be-focusable.js +3 -7
  29. package/lib/index.d.ts +28 -28
  30. package/lib/index.js +28 -33
  31. package/lib/specs/aria-specs.d.ts +4 -4
  32. package/lib/specs/aria-specs.js +1 -5
  33. package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
  34. package/lib/specs/content-model-category-to-tag-names.js +1 -5
  35. package/lib/specs/get-aria.d.ts +2 -2
  36. package/lib/specs/get-aria.js +10 -16
  37. package/lib/specs/get-attr-specs.d.ts +1 -1
  38. package/lib/specs/get-attr-specs.js +4 -9
  39. package/lib/specs/get-implicit-role.d.ts +2 -2
  40. package/lib/specs/get-implicit-role.js +3 -7
  41. package/lib/specs/get-permitted-roles.d.ts +1 -1
  42. package/lib/specs/get-permitted-roles.js +14 -17
  43. package/lib/specs/get-role-spec.d.ts +1 -1
  44. package/lib/specs/get-role-spec.js +10 -14
  45. package/lib/specs/get-selectors-by-content-model-category.d.ts +2 -2
  46. package/lib/specs/get-selectors-by-content-model-category.js +2 -6
  47. package/lib/specs/get-spec-by-tag-name.d.ts +1 -1
  48. package/lib/specs/get-spec-by-tag-name.js +4 -9
  49. package/lib/specs/is-nothing-content-model.js +3 -7
  50. package/lib/specs/is-palpable-elements.d.ts +1 -1
  51. package/lib/specs/is-palpable-elements.js +5 -10
  52. package/lib/specs/is-presentational.js +1 -5
  53. package/lib/specs/is-void-element.js +1 -5
  54. package/lib/specs/resolve-version.d.ts +2 -2
  55. package/lib/specs/resolve-version.js +7 -12
  56. package/lib/specs/schema-to-spec.d.ts +3 -3
  57. package/lib/specs/schema-to-spec.js +18 -23
  58. package/lib/types/aria.js +1 -2
  59. package/lib/types/attributes.js +1 -2
  60. package/lib/types/index.d.ts +4 -4
  61. package/lib/types/index.js +1 -2
  62. package/lib/types/permitted-structures.js +1 -2
  63. package/lib/utils/get-ns.js +1 -5
  64. package/lib/utils/merge-array.js +1 -5
  65. package/lib/utils/resolve-namespace.js +4 -9
  66. package/lib/utils/validateAriaVersion.d.ts +1 -1
  67. package/lib/utils/validateAriaVersion.js +3 -7
  68. package/package.json +12 -7
  69. package/test/dom-traverse/accname-computation.spec.js +0 -69
  70. package/test/dom-traverse/get-computed-aria-props.spec.js +0 -758
  71. package/test/dom-traverse/get-computed-role.spec.js +0 -315
  72. package/test/dom-traverse/get-implicit-role.spec.js +0 -40
  73. package/test/dom-traverse/has-required-owned-elements.spec.js +0 -34
  74. package/test/dom-traverse/is-exposed.spec.js +0 -70
  75. package/test/dom-traverse/matches-context-role.spec.js +0 -60
  76. package/test/specs/get-attr-specs.spec.js +0 -41
  77. package/test/specs/get-implicit-role.spec.js +0 -79
  78. package/test/specs/get-permitted-roles.spec.js +0 -418
  79. package/test/specs/get-role-spec.spec.js +0 -67
  80. package/test/specs/get-spec-by-tag-name.spec.js +0 -68
  81. package/test/specs/resolve-version.spec.js +0 -34
  82. package/test/specs/schema-to-spec.spec.js +0 -61
  83. package/test/utils/resolve-namespace.spec.js +0 -37
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ARIA_RECOMMENDED_VERSION = exports.ariaVersions = void 0;
4
- exports.ariaVersions = ['1.1', '1.2', '1.3'];
5
- exports.ARIA_RECOMMENDED_VERSION = '1.2';
1
+ export const ariaVersions = ['1.1', '1.2', '1.3'];
2
+ export const ARIA_RECOMMENDED_VERSION = '1.2';
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAccname = void 0;
4
- const dom_accessibility_api_1 = require("dom-accessibility-api");
5
- function getAccname(
1
+ // @ts-ignore
2
+ import { computeAccessibleName } from 'dom-accessibility-api';
3
+ export function getAccname(
6
4
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
5
  el) {
8
- return (0, dom_accessibility_api_1.computeAccessibleName)(el);
6
+ return computeAccessibleName(el);
9
7
  }
10
- exports.getAccname = getAccname;
@@ -1,2 +1,2 @@
1
- import type { MLMLSpec } from '../types';
2
- export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import("../types").Attribute[] | null;
1
+ import type { MLMLSpec } from '../types/index.js';
2
+ export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import("../types/index.js").Attribute[] | null;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAttrSpecs = void 0;
4
- const get_attr_specs_1 = require("../specs/get-attr-specs");
5
- function getAttrSpecs(
1
+ import { getAttrSpecs as _getAttrSpecs } from '../specs/get-attr-specs.js';
2
+ export function getAttrSpecs(
6
3
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
4
  el, schema) {
8
- return (0, get_attr_specs_1.getAttrSpecs)(el.localName, el.namespaceURI, schema);
5
+ return _getAttrSpecs(el.localName, el.namespaceURI, schema);
9
6
  }
10
- exports.getAttrSpecs = getAttrSpecs;
@@ -1,4 +1,4 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
2
  type ARIAProps = Record<string, ARIAProp>;
3
3
  type ARIAProp = {
4
4
  name: string;
@@ -1,19 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComputedAriaProps = void 0;
4
- const aria_specs_1 = require("../specs/aria-specs");
5
- const get_computed_role_1 = require("./get-computed-role");
6
- function getComputedAriaProps(specs,
1
+ import { ariaSpecs as _ariaSpecs } from '../specs/aria-specs.js';
2
+ import { getComputedRole } from './get-computed-role.js';
3
+ export function getComputedAriaProps(specs,
7
4
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
5
  el, version) {
9
- const ariaSpecs = (0, aria_specs_1.ariaSpecs)(specs, version);
10
- const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
6
+ const ariaSpecs = _ariaSpecs(specs, version);
7
+ const { role } = getComputedRole(specs, el, version);
11
8
  if (!role) {
12
9
  return {};
13
10
  }
14
11
  const props = {};
15
12
  role.ownedProperties.forEach(ownedProp => {
16
- var _a;
17
13
  const spec = ariaSpecs.props.find(propSpec => propSpec.name === ownedProp.name);
18
14
  if (!spec) {
19
15
  return;
@@ -31,7 +27,7 @@ el, version) {
31
27
  return;
32
28
  }
33
29
  }
34
- const equivalentHtmlAttr = (_a = spec.equivalentHtmlAttrs) === null || _a === void 0 ? void 0 : _a[0];
30
+ const equivalentHtmlAttr = spec.equivalentHtmlAttrs?.[0];
35
31
  if (equivalentHtmlAttr && el.hasAttribute(equivalentHtmlAttr.htmlAttrName)) {
36
32
  const value = equivalentHtmlAttr.value === null
37
33
  ? el.getAttribute(equivalentHtmlAttr.htmlAttrName)
@@ -64,7 +60,6 @@ el, version) {
64
60
  });
65
61
  return props;
66
62
  }
67
- exports.getComputedAriaProps = getComputedAriaProps;
68
63
  function isValidAriaValue(spec, role, value, enumList) {
69
64
  let type = spec.value;
70
65
  if (spec.conditionalValue) {
@@ -74,7 +69,7 @@ function isValidAriaValue(spec, role, value, enumList) {
74
69
  }
75
70
  }
76
71
  }
77
- value = (value !== null && value !== void 0 ? value : '').trim();
72
+ value = (value ?? '').trim();
78
73
  switch (type) {
79
74
  case 'string': {
80
75
  return true;
@@ -1,2 +1,2 @@
1
- import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
1
+ import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
2
2
  export declare function getComputedRole(specs: MLMLSpec, el: Element, version: ARIAVersion, assumeSingleNode?: boolean): ComputedRole;
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComputedRole = void 0;
4
- const aria_specs_1 = require("../specs/aria-specs");
5
- const is_presentational_1 = require("../specs/is-presentational");
6
- const accname_computation_1 = require("./accname-computation");
7
- const get_attr_specs_1 = require("./get-attr-specs");
8
- const get_explicit_role_1 = require("./get-explicit-role");
9
- const get_implicit_role_1 = require("./get-implicit-role");
10
- const get_non_presentational_ancestor_1 = require("./get-non-presentational-ancestor");
11
- const has_required_owned_elements_1 = require("./has-required-owned-elements");
12
- const matches_context_role_1 = require("./matches-context-role");
13
- const may_be_focusable_1 = require("./may-be-focusable");
14
- function getComputedRole(specs,
1
+ import { ariaSpecs } from '../specs/aria-specs.js';
2
+ import { isPresentational } from '../specs/is-presentational.js';
3
+ import { getAccname } from './accname-computation.js';
4
+ import { getAttrSpecs } from './get-attr-specs.js';
5
+ import { getExplicitRole } from './get-explicit-role.js';
6
+ import { getImplicitRole } from './get-implicit-role.js';
7
+ import { getNonPresentationalAncestor } from './get-non-presentational-ancestor.js';
8
+ import { isRequiredOwnedElement } from './has-required-owned-elements.js';
9
+ import { matchesContextRole } from './matches-context-role.js';
10
+ import { mayBeFocusable } from './may-be-focusable.js';
11
+ export function getComputedRole(specs,
15
12
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
16
13
  el, version, assumeSingleNode = false) {
17
- var _a, _b, _c, _d;
18
- const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, el, version);
19
- const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
14
+ const implicitRole = getImplicitRole(specs, el, version);
15
+ const explicitRole = getExplicitRole(specs, el, version);
20
16
  const computedRole = explicitRole.role
21
17
  ? explicitRole
22
18
  : {
@@ -68,7 +64,7 @@ el, version, assumeSingleNode = false) {
68
64
  errorType: 'NO_OWNER',
69
65
  };
70
66
  }
71
- const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
67
+ const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
72
68
  if (!nonPresentationalAncestor.role) {
73
69
  return {
74
70
  el,
@@ -76,7 +72,7 @@ el, version, assumeSingleNode = false) {
76
72
  errorType: 'NO_OWNER',
77
73
  };
78
74
  }
79
- if (!(0, matches_context_role_1.matchesContextRole)(computedRole.role.requiredContextRole, el, specs, version)) {
75
+ if (!matchesContextRole(computedRole.role.requiredContextRole, el, specs, version)) {
80
76
  return {
81
77
  el,
82
78
  role: null,
@@ -119,9 +115,10 @@ el, version, assumeSingleNode = false) {
119
115
  (explicitRole.role === null || explicitRole.errorType != null) &&
120
116
  // It is an SVG element.
121
117
  el.namespaceURI === 'http://www.w3.org/2000/svg') {
122
- const accname = (0, accname_computation_1.getAccname)(el).trim() ||
123
- ((_b = (_a = Array.from(el.children)
124
- .find(child => ['title', 'desc'].includes(child.localName))) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim());
118
+ const accname = getAccname(el).trim() ||
119
+ Array.from(el.children)
120
+ .find(child => ['title', 'desc'].includes(child.localName))
121
+ ?.textContent?.trim();
125
122
  if (!accname) {
126
123
  return {
127
124
  el,
@@ -129,7 +126,7 @@ el, version, assumeSingleNode = false) {
129
126
  };
130
127
  }
131
128
  }
132
- if (computedRole.role && !(0, is_presentational_1.isPresentational)(computedRole.role.name)) {
129
+ if (computedRole.role && !isPresentational(computedRole.role.name)) {
133
130
  return computedRole;
134
131
  }
135
132
  /**
@@ -154,7 +151,7 @@ el, version, assumeSingleNode = false) {
154
151
  * the interactive elements can not specify the presentational role
155
152
  * in the previous processing that computes the permitted role (`getExplicitRole`).
156
153
  */
157
- (0, may_be_focusable_1.mayBeFocusable)(el, specs) &&
154
+ mayBeFocusable(el, specs) &&
158
155
  /**
159
156
  * 2. No disabled
160
157
  */
@@ -183,13 +180,13 @@ el, version, assumeSingleNode = false) {
183
180
  * `role=presentation` is to be ignored absolutely.
184
181
  */
185
182
  if (explicitRole.role) {
186
- const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
187
- if (nonPresentationalAncestor.role && ((_c = nonPresentationalAncestor.role) === null || _c === void 0 ? void 0 : _c.requiredOwnedElements.length) > 0) {
183
+ const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
184
+ if (nonPresentationalAncestor.role && nonPresentationalAncestor.role?.requiredOwnedElements.length > 0) {
188
185
  if (nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
189
186
  // const ancestor = nonPresentationalAncestor.el;
190
187
  // const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
191
188
  // console.log({ nonPresentationalAncestor, ancestorImplicitRole });
192
- return (0, has_required_owned_elements_1.isRequiredOwnedElement)(implicitRole.el, implicitRole.role, expected, specs, version);
189
+ return isRequiredOwnedElement(implicitRole.el, implicitRole.role, expected, specs, version);
193
190
  })) {
194
191
  return {
195
192
  ...implicitRole,
@@ -208,9 +205,9 @@ el, version, assumeSingleNode = false) {
208
205
  * > unless the presentational role is inherited
209
206
  * > and an explicit non-presentational role is applied.
210
207
  */
211
- const { props } = (0, aria_specs_1.ariaSpecs)(specs, version);
208
+ const { props } = ariaSpecs(specs, version);
212
209
  for (const attr of Array.from(el.attributes)) {
213
- if ((_d = props.find(p => p.name === attr.name)) === null || _d === void 0 ? void 0 : _d.isGlobal) {
210
+ if (props.find(p => p.name === attr.name)?.isGlobal) {
214
211
  return {
215
212
  ...implicitRole,
216
213
  errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
@@ -219,7 +216,6 @@ el, version, assumeSingleNode = false) {
219
216
  }
220
217
  return computedRole;
221
218
  }
222
- exports.getComputedRole = getComputedRole;
223
219
  /**
224
220
  * The attribute is available in its owner element,
225
221
  * it has the attribute.
@@ -227,8 +223,8 @@ exports.getComputedRole = getComputedRole;
227
223
  function isEnabledAttr(
228
224
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
229
225
  el, specs, attrName) {
230
- const attrs = (0, get_attr_specs_1.getAttrSpecs)(el, specs);
231
- const attr = attrs === null || attrs === void 0 ? void 0 : attrs.find(attr => attr.name === attrName);
226
+ const attrs = getAttrSpecs(el, specs);
227
+ const attr = attrs?.find(attr => attr.name === attrName);
232
228
  return !!attr && el.hasAttribute(attrName);
233
229
  }
234
230
  /**
@@ -1,4 +1,4 @@
1
- import type { ElementSpec } from '../types';
1
+ import type { ElementSpec } from '../types/index.js';
2
2
  type Specs = readonly Pick<ElementSpec, 'name' | 'contentModel'>[];
3
- export declare function getContentModel(el: Element, specs: Specs): boolean | readonly (import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentRequire> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentOptional> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentOneOrMore> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentZeroOrMore> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentChoice> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentTransparent>)[] | null;
3
+ export declare function getContentModel(el: Element, specs: Specs): boolean | readonly (import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentRequire> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentOptional> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentOneOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentZeroOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentChoice> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentTransparent>)[] | null;
4
4
  export {};
@@ -1,23 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContentModel = void 0;
4
- const get_spec_1 = require("./get-spec");
1
+ import { getSpec } from './get-spec.js';
5
2
  const cachesBySpecs = new Map();
6
- function getContentModel(
3
+ export function getContentModel(
7
4
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
5
  el, specs) {
9
- var _a, _b;
10
- const cacheByEl = (_a = cachesBySpecs.get(specs)) !== null && _a !== void 0 ? _a : new Map();
6
+ const cacheByEl = cachesBySpecs.get(specs) ?? new Map();
11
7
  const cached = cacheByEl.get(el);
12
8
  if (cached !== undefined) {
13
9
  return cached;
14
10
  }
15
- const spec = (0, get_spec_1.getSpec)(el, specs);
11
+ const spec = getSpec(el, specs);
16
12
  if (!spec) {
17
13
  cacheByEl.set(el, null);
18
14
  return null;
19
15
  }
20
- const conditions = (_b = spec.contentModel.conditional) !== null && _b !== void 0 ? _b : [];
16
+ const conditions = spec.contentModel.conditional ?? [];
21
17
  for (const cond of conditions) {
22
18
  if (el.matches(cond.condition)) {
23
19
  cacheByEl.set(el, cond.contents);
@@ -27,4 +23,3 @@ el, specs) {
27
23
  cacheByEl.set(el, spec.contentModel.contents);
28
24
  return spec.contentModel.contents;
29
25
  }
30
- exports.getContentModel = getContentModel;
@@ -1,2 +1,2 @@
1
- import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
1
+ import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
2
2
  export declare function getExplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
@@ -1,17 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExplicitRole = void 0;
4
- const get_role_spec_1 = require("../specs/get-role-spec");
5
- const resolve_namespace_1 = require("../utils/resolve-namespace");
6
- const get_permitted_roles_1 = require("./get-permitted-roles");
7
- function getExplicitRole(specs,
1
+ import { getRoleSpec } from '../specs/get-role-spec.js';
2
+ import { resolveNamespace } from '../utils/resolve-namespace.js';
3
+ import { getPermittedRoles } from './get-permitted-roles.js';
4
+ export function getExplicitRole(specs,
8
5
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
6
  el, version) {
10
- var _a;
11
7
  const roleValue = el.getAttribute('role');
12
- const roleNames = (_a = roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g)) !== null && _a !== void 0 ? _a : [];
13
- const permittedRoles = (0, get_permitted_roles_1.getPermittedRoles)(el, version, specs);
14
- const { namespaceURI } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
8
+ const roleNames = roleValue?.toLowerCase().trim().split(/\s+/g) ?? [];
9
+ const permittedRoles = getPermittedRoles(el, version, specs);
10
+ const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
15
11
  let error = 'NO_EXPLICIT';
16
12
  /**
17
13
  * Resolve from values and **Handling Author Errors**
@@ -19,7 +15,7 @@ el, version) {
19
15
  * @see https://w3c.github.io/aria/#document-handling_author-errors
20
16
  */
21
17
  for (const roleName of roleNames) {
22
- const spec = (0, get_role_spec_1.getRoleSpec)(specs, roleName, namespaceURI, version);
18
+ const spec = getRoleSpec(specs, roleName, namespaceURI, version);
23
19
  /**
24
20
  * If `spec` is null, the role DOES NOT EXIST.
25
21
  *
@@ -82,9 +78,8 @@ el, version) {
82
78
  errorType: error,
83
79
  };
84
80
  }
85
- exports.getExplicitRole = getExplicitRole;
86
81
  function isLandmarkRole(role) {
87
- return role === null || role === void 0 ? void 0 : role.superClassRoles.some(su => su.name === 'landmark');
82
+ return role?.superClassRoles.some(su => su.name === 'landmark');
88
83
  }
89
84
  function isValidLandmarkRole(
90
85
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
@@ -1,3 +1,3 @@
1
- import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
1
+ import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
2
2
  export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
3
- export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("..").ImplicitRole;
3
+ export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("../index.js").ImplicitRole;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImplicitRoleName = exports.getImplicitRole = void 0;
4
- const get_implicit_role_1 = require("../specs/get-implicit-role");
5
- const get_role_spec_1 = require("../specs/get-role-spec");
6
- const resolve_namespace_1 = require("../utils/resolve-namespace");
7
- function getImplicitRole(specs,
1
+ import { getImplicitRole as _getImplicitRole } from '../specs/get-implicit-role.js';
2
+ import { getRoleSpec } from '../specs/get-role-spec.js';
3
+ import { resolveNamespace } from '../utils/resolve-namespace.js';
4
+ export function getImplicitRole(specs,
8
5
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
6
  el, version) {
10
7
  const implicitRole = getImplicitRoleName(el, version, specs);
@@ -15,8 +12,8 @@ el, version) {
15
12
  role: null,
16
13
  };
17
14
  }
18
- const { namespaceURI } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
19
- const spec = (0, get_role_spec_1.getRoleSpec)(specs, implicitRole, namespaceURI, version);
15
+ const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
16
+ const spec = getRoleSpec(specs, implicitRole, namespaceURI, version);
20
17
  if (!spec) {
21
18
  return {
22
19
  el,
@@ -32,10 +29,8 @@ el, version) {
32
29
  },
33
30
  };
34
31
  }
35
- exports.getImplicitRole = getImplicitRole;
36
- function getImplicitRoleName(
32
+ export function getImplicitRoleName(
37
33
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
38
34
  el, version, specs) {
39
- return (0, get_implicit_role_1.getImplicitRole)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
35
+ return _getImplicitRole(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
40
36
  }
41
- exports.getImplicitRoleName = getImplicitRoleName;
@@ -1,5 +1,5 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function getNonPresentationalAncestor(el: Element, specs: MLMLSpec, version: ARIAVersion): import("../types").ComputedRole | {
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
+ export declare function getNonPresentationalAncestor(el: Element, specs: MLMLSpec, version: ARIAVersion): import("../types/index.js").ComputedRole | {
3
3
  el: null;
4
4
  role: null;
5
5
  };
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNonPresentationalAncestor = void 0;
4
- const is_presentational_1 = require("../specs/is-presentational");
5
- const get_computed_role_1 = require("./get-computed-role");
6
- function getNonPresentationalAncestor(
1
+ import { isPresentational } from '../specs/is-presentational.js';
2
+ import { getComputedRole } from './get-computed-role.js';
3
+ export function getNonPresentationalAncestor(
7
4
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
5
  el, specs, version) {
9
- var _a;
10
6
  let ancestor = el.parentElement;
11
7
  /**
12
8
  * In ARIA 1.1 and 1.2, the role of an element is not affected by the role of its ancestor elements.
@@ -15,8 +11,8 @@ el, specs, version) {
15
11
  */
16
12
  const assumeSingleNode = version !== '1.1' && version !== '1.2';
17
13
  while (ancestor) {
18
- const ancestorRole = (0, get_computed_role_1.getComputedRole)(specs, ancestor, version, assumeSingleNode);
19
- if (!(0, is_presentational_1.isPresentational)((_a = ancestorRole.role) === null || _a === void 0 ? void 0 : _a.name)) {
14
+ const ancestorRole = getComputedRole(specs, ancestor, version, assumeSingleNode);
15
+ if (!isPresentational(ancestorRole.role?.name)) {
20
16
  return ancestorRole;
21
17
  }
22
18
  ancestor = ancestor.parentElement;
@@ -26,4 +22,3 @@ el, specs, version) {
26
22
  role: null,
27
23
  };
28
24
  }
29
- exports.getNonPresentationalAncestor = getNonPresentationalAncestor;
@@ -1,4 +1,4 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
2
  export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: MLMLSpec): readonly {
3
3
  readonly name: string;
4
4
  readonly deprecated?: boolean | undefined;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPermittedRoles = void 0;
4
- const get_permitted_roles_1 = require("../specs/get-permitted-roles");
5
- function getPermittedRoles(
1
+ import { getPermittedRoles as _getPermittedRoles } from '../specs/get-permitted-roles.js';
2
+ export function getPermittedRoles(
6
3
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
4
  el, version, specs) {
8
- return (0, get_permitted_roles_1.getPermittedRoles)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
5
+ return _getPermittedRoles(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
9
6
  }
10
- exports.getPermittedRoles = getPermittedRoles;
@@ -1,2 +1,2 @@
1
- import type { ElementSpec } from '../types';
1
+ import type { ElementSpec } from '../types/index.js';
2
2
  export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: readonly Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSpec = void 0;
4
- const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
5
- function getSpec(
1
+ import { getSpecByTagName } from '../specs/get-spec-by-tag-name.js';
2
+ export function getSpec(
6
3
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
4
  el, specs) {
8
- return (0, get_spec_by_tag_name_1.getSpecByTagName)(specs, el.localName, el.namespaceURI);
5
+ return getSpecByTagName(specs, el.localName, el.namespaceURI);
9
6
  }
10
- exports.getSpec = getSpec;
@@ -1,3 +1,3 @@
1
- import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
1
+ import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
2
2
  export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
3
3
  export declare function isRequiredOwnedElement(el: Element, role: ComputedRole['role'], query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
@@ -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
69
  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);
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
  *