@markuplint/ml-spec 3.0.0-dev.24 → 3.0.0-dev.290

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 (131) hide show
  1. package/lib/constant/aria-version.d.ts +2 -0
  2. package/lib/constant/aria-version.js +2 -0
  3. package/lib/dom-traverse/accname-computation.js +6 -7
  4. package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
  5. package/lib/dom-traverse/get-attr-specs.js +5 -7
  6. package/lib/dom-traverse/get-computed-aria-props.d.ts +2 -2
  7. package/lib/dom-traverse/get-computed-aria-props.js +10 -13
  8. package/lib/dom-traverse/get-computed-role.d.ts +2 -2
  9. package/lib/dom-traverse/get-computed-role.js +104 -31
  10. package/lib/dom-traverse/get-content-model.d.ts +4 -3
  11. package/lib/dom-traverse/get-content-model.js +8 -11
  12. package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
  13. package/lib/dom-traverse/get-explicit-role.js +14 -14
  14. package/lib/dom-traverse/get-implicit-role.d.ts +3 -3
  15. package/lib/dom-traverse/get-implicit-role.js +12 -13
  16. package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
  17. package/lib/dom-traverse/get-non-presentational-ancestor.js +13 -10
  18. package/lib/dom-traverse/get-permitted-roles.d.ts +4 -4
  19. package/lib/dom-traverse/get-permitted-roles.js +5 -7
  20. package/lib/dom-traverse/get-spec.d.ts +2 -2
  21. package/lib/dom-traverse/get-spec.js +5 -7
  22. package/lib/dom-traverse/has-required-owned-elements.d.ts +3 -3
  23. package/lib/dom-traverse/has-required-owned-elements.js +21 -22
  24. package/lib/dom-traverse/is-exposed.d.ts +2 -2
  25. package/lib/dom-traverse/is-exposed.js +47 -18
  26. package/lib/dom-traverse/matches-context-role.d.ts +2 -0
  27. package/lib/dom-traverse/matches-context-role.js +23 -0
  28. package/lib/dom-traverse/may-be-focusable.d.ts +2 -2
  29. package/lib/dom-traverse/may-be-focusable.js +5 -7
  30. package/lib/index.d.ts +28 -24
  31. package/lib/index.js +28 -27
  32. package/lib/specs/aria-specs.d.ts +5 -5
  33. package/lib/specs/aria-specs.js +1 -5
  34. package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
  35. package/lib/specs/content-model-category-to-tag-names.js +1 -5
  36. package/lib/specs/get-aria.d.ts +4 -3
  37. package/lib/specs/get-aria.js +18 -18
  38. package/lib/specs/get-attr-specs.d.ts +3 -3
  39. package/lib/specs/get-attr-specs.js +5 -22
  40. package/lib/specs/get-implicit-role.d.ts +2 -2
  41. package/lib/specs/get-implicit-role.js +3 -7
  42. package/lib/specs/get-permitted-roles.d.ts +4 -4
  43. package/lib/specs/get-permitted-roles.js +29 -28
  44. package/lib/specs/get-role-spec.d.ts +2 -2
  45. package/lib/specs/get-role-spec.js +10 -14
  46. package/lib/specs/get-selectors-by-content-model-category.d.ts +3 -3
  47. package/lib/specs/get-selectors-by-content-model-category.js +2 -6
  48. package/lib/specs/get-spec-by-tag-name.d.ts +2 -2
  49. package/lib/specs/get-spec-by-tag-name.js +4 -8
  50. package/lib/specs/is-nothing-content-model.js +5 -7
  51. package/lib/specs/is-palpable-elements.d.ts +4 -4
  52. package/lib/specs/is-palpable-elements.js +7 -10
  53. package/lib/specs/is-presentational.js +1 -5
  54. package/lib/specs/is-void-element.js +3 -5
  55. package/lib/specs/resolve-version.d.ts +4 -3
  56. package/lib/specs/resolve-version.js +7 -12
  57. package/lib/specs/schema-to-spec.d.ts +4 -4
  58. package/lib/specs/schema-to-spec.js +30 -24
  59. package/lib/types/aria.d.ts +25 -4
  60. package/lib/types/aria.js +1 -3
  61. package/lib/types/attributes.d.ts +3 -4
  62. package/lib/types/attributes.js +1 -3
  63. package/lib/types/index.d.ts +93 -92
  64. package/lib/types/index.js +1 -2
  65. package/lib/types/permitted-structures.d.ts +6 -2
  66. package/lib/types/permitted-structures.js +1 -3
  67. package/lib/utils/get-ns.js +1 -5
  68. package/lib/utils/merge-array.d.ts +2 -2
  69. package/lib/utils/merge-array.js +1 -5
  70. package/lib/utils/resolve-namespace.js +4 -8
  71. package/lib/utils/validateAriaVersion.d.ts +2 -0
  72. package/lib/utils/validateAriaVersion.js +4 -0
  73. package/package.json +20 -10
  74. package/lib/types/permitted-structres.d.ts +0 -58
  75. package/lib/types/permitted-structres.js +0 -8
  76. package/schemas/aria.schema.json +0 -258
  77. package/schemas/attributes.schema.json +0 -204
  78. package/schemas/content-models.schema.json +0 -199
  79. package/schemas/element.schema.json +0 -11
  80. package/schemas/global-attributes.schema.json +0 -761
  81. package/src/dom-traverse/accname-computation.spec.ts +0 -69
  82. package/src/dom-traverse/accname-computation.ts +0 -5
  83. package/src/dom-traverse/get-attr-specs.ts +0 -8
  84. package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
  85. package/src/dom-traverse/get-computed-aria-props.ts +0 -130
  86. package/src/dom-traverse/get-computed-role.spec.ts +0 -134
  87. package/src/dom-traverse/get-computed-role.ts +0 -181
  88. package/src/dom-traverse/get-content-model.ts +0 -32
  89. package/src/dom-traverse/get-explicit-role.ts +0 -112
  90. package/src/dom-traverse/get-implicit-role.ts +0 -36
  91. package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
  92. package/src/dom-traverse/get-permitted-roles.ts +0 -7
  93. package/src/dom-traverse/get-spec.ts +0 -7
  94. package/src/dom-traverse/has-required-owned-elements.spec.ts +0 -36
  95. package/src/dom-traverse/has-required-owned-elements.ts +0 -85
  96. package/src/dom-traverse/is-exposed.spec.ts +0 -50
  97. package/src/dom-traverse/is-exposed.ts +0 -196
  98. package/src/dom-traverse/may-be-focusable.ts +0 -21
  99. package/src/index.ts +0 -24
  100. package/src/specs/aria-specs.ts +0 -6
  101. package/src/specs/content-model-category-to-tag-names.ts +0 -15
  102. package/src/specs/get-aria.ts +0 -85
  103. package/src/specs/get-attr-specs.spec.ts +0 -47
  104. package/src/specs/get-attr-specs.ts +0 -116
  105. package/src/specs/get-implicit-role.spec.ts +0 -81
  106. package/src/specs/get-implicit-role.ts +0 -17
  107. package/src/specs/get-permitted-roles.spec.ts +0 -420
  108. package/src/specs/get-permitted-roles.ts +0 -87
  109. package/src/specs/get-role-spec.spec.ts +0 -67
  110. package/src/specs/get-role-spec.ts +0 -72
  111. package/src/specs/get-selectors-by-content-model-category.ts +0 -10
  112. package/src/specs/get-spec-by-tag-name.spec.ts +0 -68
  113. package/src/specs/get-spec-by-tag-name.ts +0 -20
  114. package/src/specs/is-nothing-content-model.ts +0 -9
  115. package/src/specs/is-palpable-elements.ts +0 -55
  116. package/src/specs/is-presentational.ts +0 -6
  117. package/src/specs/is-void-element.ts +0 -22
  118. package/src/specs/resolve-version.ts +0 -20
  119. package/src/specs/schema-to-spec.spec.ts +0 -39
  120. package/src/specs/schema-to-spec.ts +0 -103
  121. package/src/types/aria.ts +0 -153
  122. package/src/types/attributes.ts +0 -1524
  123. package/src/types/index.ts +0 -255
  124. package/src/types/permitted-structres.ts +0 -100
  125. package/src/types/permitted-structures.ts +0 -96
  126. package/src/utils/get-ns.ts +0 -18
  127. package/src/utils/merge-array.ts +0 -35
  128. package/src/utils/resolve-namespace.spec.ts +0 -37
  129. package/src/utils/resolve-namespace.ts +0 -40
  130. package/tsconfig.test.json +0 -3
  131. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,2 @@
1
+ export declare const ariaVersions: readonly ["1.1", "1.2", "1.3"];
2
+ export declare const ARIA_RECOMMENDED_VERSION: "1.2";
@@ -0,0 +1,2 @@
1
+ export const ariaVersions = ['1.1', '1.2', '1.3'];
2
+ export const ARIA_RECOMMENDED_VERSION = '1.2';
@@ -1,8 +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(el) {
6
- return (0, dom_accessibility_api_1.computeAccessibleName)(el);
1
+ // @ts-ignore
2
+ import { computeAccessibleName } from 'dom-accessibility-api';
3
+ export function getAccname(
4
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
5
+ el) {
6
+ return computeAccessibleName(el);
7
7
  }
8
- exports.getAccname = getAccname;
@@ -1,2 +1,2 @@
1
- import type { MLMLSpec } from '../types';
2
- export declare function getAttrSpecs(el: Element, schema: MLMLSpec): 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,8 +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(el, schema) {
6
- return (0, get_attr_specs_1.getAttrSpecs)(el.localName, el.namespaceURI, schema);
1
+ import { getAttrSpecs as _getAttrSpecs } from '../specs/get-attr-specs.js';
2
+ export function getAttrSpecs(
3
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
4
+ el, schema) {
5
+ return _getAttrSpecs(el.localName, el.namespaceURI, schema);
7
6
  }
8
- 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;
@@ -8,5 +8,5 @@ type ARIAProp = {
8
8
  from: ARIAPropReferenceType;
9
9
  };
10
10
  type ARIAPropReferenceType = 'default' | 'html-attr' | 'aria-attr';
11
- export declare function getComputedAriaProps(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ARIAProps;
11
+ export declare function getComputedAriaProps(specs: MLMLSpec, el: Element, version: ARIAVersion): ARIAProps;
12
12
  export {};
@@ -1,17 +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, el, version) {
7
- const ariaSpecs = (0, aria_specs_1.ariaSpecs)(specs, version);
8
- const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
1
+ import { ariaSpecs as _ariaSpecs } from '../specs/aria-specs.js';
2
+ import { getComputedRole } from './get-computed-role.js';
3
+ export function getComputedAriaProps(specs,
4
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
5
+ el, version) {
6
+ const ariaSpecs = _ariaSpecs(specs, version);
7
+ const { role } = getComputedRole(specs, el, version);
9
8
  if (!role) {
10
9
  return {};
11
10
  }
12
11
  const props = {};
13
12
  role.ownedProperties.forEach(ownedProp => {
14
- var _a;
15
13
  const spec = ariaSpecs.props.find(propSpec => propSpec.name === ownedProp.name);
16
14
  if (!spec) {
17
15
  return;
@@ -29,7 +27,7 @@ function getComputedAriaProps(specs, el, version) {
29
27
  return;
30
28
  }
31
29
  }
32
- const equivalentHtmlAttr = (_a = spec.equivalentHtmlAttrs) === null || _a === void 0 ? void 0 : _a[0];
30
+ const equivalentHtmlAttr = spec.equivalentHtmlAttrs?.[0];
33
31
  if (equivalentHtmlAttr && el.hasAttribute(equivalentHtmlAttr.htmlAttrName)) {
34
32
  const value = equivalentHtmlAttr.value === null
35
33
  ? el.getAttribute(equivalentHtmlAttr.htmlAttrName)
@@ -62,7 +60,6 @@ function getComputedAriaProps(specs, el, version) {
62
60
  });
63
61
  return props;
64
62
  }
65
- exports.getComputedAriaProps = getComputedAriaProps;
66
63
  function isValidAriaValue(spec, role, value, enumList) {
67
64
  let type = spec.value;
68
65
  if (spec.conditionalValue) {
@@ -72,7 +69,7 @@ function isValidAriaValue(spec, role, value, enumList) {
72
69
  }
73
70
  }
74
71
  }
75
- value = (value !== null && value !== void 0 ? value : '').trim();
72
+ value = (value ?? '').trim();
76
73
  switch (type) {
77
74
  case 'string': {
78
75
  return true;
@@ -88,7 +85,7 @@ function isValidAriaValue(spec, role, value, enumList) {
88
85
  }
89
86
  case 'token':
90
87
  case 'token list': {
91
- if (!enumList.length) {
88
+ if (enumList.length === 0) {
92
89
  throw new Error('Need an enum list in token and token list types');
93
90
  }
94
91
  return enumList.includes(value.toLowerCase());
@@ -1,2 +1,2 @@
1
- import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
2
- export declare function getComputedRole(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ComputedRole;
1
+ import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
2
+ export declare function getComputedRole(specs: MLMLSpec, el: Element, version: ARIAVersion, assumeSingleNode?: boolean): ComputedRole;
@@ -1,19 +1,30 @@
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 get_attr_specs_1 = require("./get-attr-specs");
7
- const get_explicit_role_1 = require("./get-explicit-role");
8
- const get_implicit_role_1 = require("./get-implicit-role");
9
- const get_non_presentational_ancestor_1 = require("./get-non-presentational-ancestor");
10
- const has_required_owned_elements_1 = require("./has-required-owned-elements");
11
- const may_be_focusable_1 = require("./may-be-focusable");
12
- function getComputedRole(specs, el, version) {
13
- var _a, _b, _c, _d;
14
- const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, el, version);
15
- const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
16
- const computedRole = explicitRole.role ? explicitRole : implicitRole;
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,
12
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
13
+ el, version, assumeSingleNode = false) {
14
+ const implicitRole = getImplicitRole(specs, el, version);
15
+ const explicitRole = getExplicitRole(specs, el, version);
16
+ const computedRole = explicitRole.role
17
+ ? explicitRole
18
+ : {
19
+ ...implicitRole,
20
+ errorType: explicitRole.errorType === 'NO_EXPLICIT' ? undefined : explicitRole.errorType,
21
+ };
22
+ if (assumeSingleNode) {
23
+ return {
24
+ ...computedRole,
25
+ errorType: 'NO_OWNER',
26
+ };
27
+ }
17
28
  /**
18
29
  * Presentational Roles Conflict Resolution
19
30
  *
@@ -39,8 +50,21 @@ function getComputedRole(specs, el, version) {
39
50
  * However, the presentational role behaves transparently
40
51
  * according to the sample code in WAI-ARIA specification.
41
52
  */
42
- if ((_a = computedRole.role) === null || _a === void 0 ? void 0 : _a.requiredContextRole.length) {
43
- const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
53
+ if (computedRole.role && computedRole.role.requiredContextRole.length > 0) {
54
+ /**
55
+ * An element fragment that serves as the root without a parent element
56
+ * cannot satisfy the "Required Context Role" condition.
57
+ * Therefore, under normal circumstances, the `role` will disappear.
58
+ * However, in this specific case, it will fall back to both explicit
59
+ * and implicit roles. Note that the explicit role takes precedence.
60
+ */
61
+ if (el.parentElement === null) {
62
+ return {
63
+ ...computedRole,
64
+ errorType: 'NO_OWNER',
65
+ };
66
+ }
67
+ const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
44
68
  if (!nonPresentationalAncestor.role) {
45
69
  return {
46
70
  el,
@@ -48,7 +72,7 @@ function getComputedRole(specs, el, version) {
48
72
  errorType: 'NO_OWNER',
49
73
  };
50
74
  }
51
- if (!((_b = computedRole.role) === null || _b === void 0 ? void 0 : _b.requiredContextRole.includes(nonPresentationalAncestor.role.name))) {
75
+ if (!matchesContextRole(computedRole.role.requiredContextRole, el, specs, version)) {
52
76
  return {
53
77
  el,
54
78
  role: null,
@@ -56,7 +80,53 @@ function getComputedRole(specs, el, version) {
56
80
  };
57
81
  }
58
82
  }
59
- if (computedRole.role && !(0, is_presentational_1.isPresentational)(computedRole.role.name)) {
83
+ /**
84
+ * SVG: Including Elements in the Accessibility Tree
85
+ *
86
+ * > Many SVG elements—although rendered to the screen—
87
+ * > do not have an intrinsic semantic meaning. Instead,
88
+ * > they represent components of the visual presentation of the document.
89
+ * > To simplify the accessible representation of the document,
90
+ * > these purely presentational elements should normally be omitted
91
+ * > from the accessibility tree, unless the author explicitly provides semantic content.
92
+ * >
93
+ * > However, any rendered SVG element may have semantic meaning.
94
+ * > Authors indicate the significance of the element
95
+ * > by including alternative text content or WAI-ARIA attributes.
96
+ * > This section defines the rules for including normally-omitted elements
97
+ * > in the accessibility tree.
98
+ * >
99
+ * > The following graphical and container elements
100
+ * > in the SVG namespace SHOULD NOT be included in the accessibility tree,
101
+ * > except as described in this section:
102
+ * >
103
+ * > - shape elements (circle, ellipse, line, path, polygon, polyline, rect)
104
+ * > - the use element
105
+ * > - the grouping (g) element
106
+ * > - the image element
107
+ * > - the mesh element
108
+ * > - text formatting elements (textPath, tspan)
109
+ * > - the foreignObject element
110
+ *
111
+ * @see https://www.w3.org/TR/svg-aam-1.0/#include_elements
112
+ */
113
+ if (
114
+ // It doesn't been specified a valid explicit role.
115
+ (explicitRole.role === null || explicitRole.errorType != null) &&
116
+ // It is an SVG element.
117
+ el.namespaceURI === 'http://www.w3.org/2000/svg') {
118
+ const accname = getAccname(el).trim() ||
119
+ Array.from(el.children)
120
+ .find(child => ['title', 'desc'].includes(child.localName))
121
+ ?.textContent?.trim();
122
+ if (!accname) {
123
+ return {
124
+ el,
125
+ role: null,
126
+ };
127
+ }
128
+ }
129
+ if (computedRole.role && !isPresentational(computedRole.role.name)) {
60
130
  return computedRole;
61
131
  }
62
132
  /**
@@ -81,7 +151,7 @@ function getComputedRole(specs, el, version) {
81
151
  * the interactive elements can not specify the presentational role
82
152
  * in the previous processing that computes the permitted role (`getExplicitRole`).
83
153
  */
84
- (0, may_be_focusable_1.mayBeFocusable)(el, specs) &&
154
+ mayBeFocusable(el, specs) &&
85
155
  /**
86
156
  * 2. No disabled
87
157
  */
@@ -110,13 +180,13 @@ function getComputedRole(specs, el, version) {
110
180
  * `role=presentation` is to be ignored absolutely.
111
181
  */
112
182
  if (explicitRole.role) {
113
- const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
114
- if ((_c = nonPresentationalAncestor.role) === null || _c === void 0 ? void 0 : _c.requiredOwnedElements.length) {
183
+ const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
184
+ if (nonPresentationalAncestor.role && nonPresentationalAncestor.role?.requiredOwnedElements.length > 0) {
115
185
  if (nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
116
186
  // const ancestor = nonPresentationalAncestor.el;
117
187
  // const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
118
188
  // console.log({ nonPresentationalAncestor, ancestorImplicitRole });
119
- return (0, has_required_owned_elements_1.isRequiredOwnedElement)(implicitRole, expected, specs, version);
189
+ return isRequiredOwnedElement(implicitRole.el, implicitRole.role, expected, specs, version);
120
190
  })) {
121
191
  return {
122
192
  ...implicitRole,
@@ -135,9 +205,9 @@ function getComputedRole(specs, el, version) {
135
205
  * > unless the presentational role is inherited
136
206
  * > and an explicit non-presentational role is applied.
137
207
  */
138
- const { props } = (0, aria_specs_1.ariaSpecs)(specs, version);
208
+ const { props } = ariaSpecs(specs, version);
139
209
  for (const attr of Array.from(el.attributes)) {
140
- 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) {
141
211
  return {
142
212
  ...implicitRole,
143
213
  errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
@@ -146,20 +216,23 @@ function getComputedRole(specs, el, version) {
146
216
  }
147
217
  return computedRole;
148
218
  }
149
- exports.getComputedRole = getComputedRole;
150
219
  /**
151
220
  * The attribute is available in its owner element,
152
221
  * it has the attribute.
153
222
  */
154
- function isEnabledAttr(el, specs, attrName) {
155
- const attrs = (0, get_attr_specs_1.getAttrSpecs)(el, specs);
156
- const attr = attrs === null || attrs === void 0 ? void 0 : attrs.find(attr => attr.name === attrName);
223
+ function isEnabledAttr(
224
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
225
+ el, specs, attrName) {
226
+ const attrs = getAttrSpecs(el, specs);
227
+ const attr = attrs?.find(attr => attr.name === attrName);
157
228
  return !!attr && el.hasAttribute(attrName);
158
229
  }
159
230
  /**
160
231
  * Determines whether some ancestors match the condition that the specified callback function.
161
232
  */
162
- function someAncestors(el, predicate) {
233
+ function someAncestors(
234
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
235
+ el, predicate) {
163
236
  const list = [];
164
237
  let current = el;
165
238
  while (current) {
@@ -1,3 +1,4 @@
1
- import type { ElementSpec } from '../types';
2
- import type { PermittedContentPattern } from '../types/permitted-structures';
3
- export declare function getContentModel(el: Element, specs: Pick<ElementSpec, 'name' | 'contentModel'>[]): boolean | PermittedContentPattern[] | null;
1
+ import type { ElementSpec } from '../types/index.js';
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.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
+ export {};
@@ -1,21 +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(el, specs) {
7
- var _a, _b;
8
- const cacheByEl = (_a = cachesBySpecs.get(specs)) !== null && _a !== void 0 ? _a : new Map();
3
+ export function getContentModel(
4
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
5
+ el, specs) {
6
+ const cacheByEl = cachesBySpecs.get(specs) ?? new Map();
9
7
  const cached = cacheByEl.get(el);
10
- if (cached) {
8
+ if (cached !== undefined) {
11
9
  return cached;
12
10
  }
13
- const spec = (0, get_spec_1.getSpec)(el, specs);
11
+ const spec = getSpec(el, specs);
14
12
  if (!spec) {
15
13
  cacheByEl.set(el, null);
16
14
  return null;
17
15
  }
18
- const conditions = (_b = spec.contentModel.conditional) !== null && _b !== void 0 ? _b : [];
16
+ const conditions = spec.contentModel.conditional ?? [];
19
17
  for (const cond of conditions) {
20
18
  if (el.matches(cond.condition)) {
21
19
  cacheByEl.set(el, cond.contents);
@@ -25,4 +23,3 @@ function getContentModel(el, specs) {
25
23
  cacheByEl.set(el, spec.contentModel.contents);
26
24
  return spec.contentModel.contents;
27
25
  }
28
- 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,14 +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, el, version) {
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,
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ el, version) {
8
7
  const roleValue = el.getAttribute('role');
9
- const roleNames = (roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g)) || [];
10
- const permittedRoles = (0, get_permitted_roles_1.getPermittedRoles)(el, version, specs);
11
- 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);
12
11
  let error = 'NO_EXPLICIT';
13
12
  /**
14
13
  * Resolve from values and **Handling Author Errors**
@@ -16,7 +15,7 @@ function getExplicitRole(specs, el, version) {
16
15
  * @see https://w3c.github.io/aria/#document-handling_author-errors
17
16
  */
18
17
  for (const roleName of roleNames) {
19
- const spec = (0, get_role_spec_1.getRoleSpec)(specs, roleName, namespaceURI, version);
18
+ const spec = getRoleSpec(specs, roleName, namespaceURI, version);
20
19
  /**
21
20
  * If `spec` is null, the role DOES NOT EXIST.
22
21
  *
@@ -79,11 +78,12 @@ function getExplicitRole(specs, el, version) {
79
78
  errorType: error,
80
79
  };
81
80
  }
82
- exports.getExplicitRole = getExplicitRole;
83
81
  function isLandmarkRole(role) {
84
- return role === null || role === void 0 ? void 0 : role.superClassRoles.some(su => su.name === 'landmark');
82
+ return role?.superClassRoles.some(su => su.name === 'landmark');
85
83
  }
86
- function isValidLandmarkRole(el, role) {
84
+ function isValidLandmarkRole(
85
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
86
+ el, role) {
87
87
  if (!role.accessibleNameRequired) {
88
88
  return true;
89
89
  }
@@ -1,3 +1,3 @@
1
- import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
2
- export declare function getImplicitRole(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ComputedRole;
3
- export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: Readonly<MLMLSpec>): import("..").ImplicitRole;
1
+ import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
2
+ export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
3
+ export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("../index.js").ImplicitRole;
@@ -1,10 +1,9 @@
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, el, version) {
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,
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ el, version) {
8
7
  const implicitRole = getImplicitRoleName(el, version, specs);
9
8
  if (implicitRole === false) {
10
9
  // No Corresponding Role
@@ -13,8 +12,8 @@ function getImplicitRole(specs, el, version) {
13
12
  role: null,
14
13
  };
15
14
  }
16
- const { namespaceURI } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
17
- 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);
18
17
  if (!spec) {
19
18
  return {
20
19
  el,
@@ -30,8 +29,8 @@ function getImplicitRole(specs, el, version) {
30
29
  },
31
30
  };
32
31
  }
33
- exports.getImplicitRole = getImplicitRole;
34
- function getImplicitRoleName(el, version, specs) {
35
- return (0, get_implicit_role_1.getImplicitRole)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
32
+ export function getImplicitRoleName(
33
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
34
+ el, version, specs) {
35
+ return _getImplicitRole(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
36
36
  }
37
- 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,14 +1,18 @@
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(el, specs, version) {
7
- var _a;
1
+ import { isPresentational } from '../specs/is-presentational.js';
2
+ import { getComputedRole } from './get-computed-role.js';
3
+ export function getNonPresentationalAncestor(
4
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
5
+ el, specs, version) {
8
6
  let ancestor = el.parentElement;
7
+ /**
8
+ * In ARIA 1.1 and 1.2, the role of an element is not affected by the role of its ancestor elements.
9
+ *
10
+ * It is due to implementation considerations in Markuplint.
11
+ */
12
+ const assumeSingleNode = version !== '1.1' && version !== '1.2';
9
13
  while (ancestor) {
10
- const ancestorRole = (0, get_computed_role_1.getComputedRole)(specs, ancestor, version);
11
- 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)) {
12
16
  return ancestorRole;
13
17
  }
14
18
  ancestor = ancestor.parentElement;
@@ -18,4 +22,3 @@ function getNonPresentationalAncestor(el, specs, version) {
18
22
  role: null,
19
23
  };
20
24
  }
21
- exports.getNonPresentationalAncestor = getNonPresentationalAncestor;
@@ -1,5 +1,5 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: Readonly<MLMLSpec>): {
3
- name: string;
4
- deprecated?: boolean | undefined;
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
+ export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: MLMLSpec): readonly {
3
+ readonly name: string;
4
+ readonly deprecated?: boolean | undefined;
5
5
  }[];
@@ -1,8 +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(el, version, specs) {
6
- return (0, get_permitted_roles_1.getPermittedRoles)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
1
+ import { getPermittedRoles as _getPermittedRoles } from '../specs/get-permitted-roles.js';
2
+ export function getPermittedRoles(
3
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
4
+ el, version, specs) {
5
+ return _getPermittedRoles(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
7
6
  }
8
- exports.getPermittedRoles = getPermittedRoles;
@@ -1,2 +1,2 @@
1
- import type { ElementSpec } from '../types';
2
- export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
1
+ import type { ElementSpec } from '../types/index.js';
2
+ export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: readonly Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
@@ -1,8 +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(el, specs) {
6
- return (0, get_spec_by_tag_name_1.getSpecByTagName)(specs, el.localName, el.namespaceURI);
1
+ import { getSpecByTagName } from '../specs/get-spec-by-tag-name.js';
2
+ export function getSpec(
3
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
4
+ el, specs) {
5
+ return getSpecByTagName(specs, el.localName, el.namespaceURI);
7
6
  }
8
- exports.getSpec = getSpec;
@@ -1,3 +1,3 @@
1
- import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
2
- export declare function hasRequiredOwnedElement(el: Element, specs: Readonly<MLMLSpec>, version: ARIAVersion): boolean;
3
- export declare function isRequiredOwnedElement(owned: ComputedRole, query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
1
+ import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
2
+ export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
3
+ export declare function isRequiredOwnedElement(el: Element, role: ComputedRole['role'], query: string, specs: MLMLSpec, version: ARIAVersion): boolean;