@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
@@ -1,11 +1,10 @@
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(el, specs, version) {
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(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ el, specs, version) {
9
8
  /**
10
9
  * The element has aria-owns which means it may have owned elements.
11
10
  *
@@ -18,37 +17,36 @@ function hasRequiredOwnedElement(el, specs, version) {
18
17
  /**
19
18
  * Otherwise, traverses descendants to find owned elements.
20
19
  */
21
- const computed = (0, get_computed_role_1.getComputedRole)(specs, el, version);
20
+ const computed = getComputedRole(specs, el, version);
22
21
  if (!computed.role || computed.role.requiredOwnedElements.length === 0) {
23
22
  return true;
24
23
  }
25
24
  for (const expectRole of computed.role.requiredOwnedElements) {
26
25
  for (const owned of getClosestNonPresentationalDescendants(el, specs, version)) {
27
- if (isRequiredOwnedElement(owned, expectRole, specs, version)) {
26
+ if (isRequiredOwnedElement(owned.el, owned.role, expectRole, specs, version)) {
28
27
  return true;
29
28
  }
30
29
  }
31
30
  }
32
31
  return false;
33
32
  }
34
- exports.hasRequiredOwnedElement = hasRequiredOwnedElement;
35
- function isRequiredOwnedElement(owned, query, specs, version) {
36
- var _a, _b;
33
+ export function isRequiredOwnedElement(
34
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
35
+ el, role, query, specs, version) {
37
36
  const [baseRole, owningRole] = query.split(' > ');
38
- if (((_a = owned.role) === null || _a === void 0 ? void 0 : _a.name) !== baseRole) {
37
+ if (role?.name !== baseRole) {
39
38
  return false;
40
39
  }
41
40
  if (!owningRole) {
42
41
  return true;
43
42
  }
44
- for (const owning of getClosestNonPresentationalDescendants(owned.el, specs, version)) {
45
- if (((_b = owning.role) === null || _b === void 0 ? void 0 : _b.name) === owningRole) {
43
+ for (const owning of getClosestNonPresentationalDescendants(el, specs, version)) {
44
+ if (owning.role?.name === owningRole) {
46
45
  return true;
47
46
  }
48
47
  }
49
48
  return false;
50
49
  }
51
- exports.isRequiredOwnedElement = isRequiredOwnedElement;
52
50
  /**
53
51
  * Gets the list of closest non-presentational descendants.
54
52
  * ⚠ THE SPECIFICATION HAS AN ISSUE
@@ -64,14 +62,15 @@ exports.isRequiredOwnedElement = isRequiredOwnedElement;
64
62
  * However, the presentational role behaves transparently
65
63
  * according to the sample code in WAI-ARIA specification.
66
64
  */
67
- function getClosestNonPresentationalDescendants(el, specs, version) {
68
- var _a;
65
+ function getClosestNonPresentationalDescendants(
66
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
67
+ el, specs, version) {
69
68
  const owned = [];
70
69
  for (const child of Array.from(el.children)) {
71
- const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, child, version);
72
- 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);
73
72
  const computed = explicitRole.role ? explicitRole : implicitRole;
74
- if ((0, is_presentational_1.isPresentational)((_a = computed.role) === null || _a === void 0 ? void 0 : _a.name)) {
73
+ if (isPresentational(computed.role?.name)) {
75
74
  owned.push(...getClosestNonPresentationalDescendants(child, specs, version));
76
75
  continue;
77
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
  *
@@ -8,4 +8,4 @@ import type { ARIAVersion, MLMLSpec } from '../types';
8
8
  * @param el
9
9
  * @param version
10
10
  */
11
- export declare function isExposed(el: Element, specs: Readonly<MLMLSpec>, version: ARIAVersion): boolean;
11
+ export declare function isExposed(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
@@ -1,10 +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 is_palpable_elements_1 = require("../specs/is-palpable-elements");
6
- const is_presentational_1 = require("../specs/is-presentational");
7
- 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';
8
6
  /**
9
7
  * Detect including/excluding from the Accessibility Tree
10
8
  *
@@ -14,14 +12,22 @@ const get_computed_role_1 = require("./get-computed-role");
14
12
  * @param el
15
13
  * @param version
16
14
  */
17
- function isExposed(el, specs, version) {
15
+ export function isExposed(
16
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
17
+ el, specs, version) {
18
18
  // According to WAI-ARIA
19
19
  if (isExcluding(el, specs, version)) {
20
20
  return false;
21
21
  }
22
+ // Return true if the element is unknown, deprecated, or obsolete.
23
+ const { localName, namespace } = resolveNamespace(el.localName, el.namespaceURI);
24
+ const spec = getSpecByTagName(specs.specs, localName, namespace);
25
+ if (!spec || spec.deprecated || spec.obsolete != null) {
26
+ return true;
27
+ }
22
28
  // According to HTML and SVG Specs with **the author's interpretation**
23
29
  {
24
- if (!(0, is_palpable_elements_1.isPalpableElement)(el, specs, { extendsSvg: true, extendsExposableElements: true })) {
30
+ if (!isExposedElement(el, specs)) {
25
31
  return false;
26
32
  }
27
33
  }
@@ -35,7 +41,6 @@ function isExposed(el, specs, version) {
35
41
  // Default
36
42
  return true;
37
43
  }
38
- exports.isExposed = isExposed;
39
44
  /**
40
45
  * Excluding Elements from the Accessibility Tree
41
46
  *
@@ -45,7 +50,9 @@ exports.isExposed = isExposed;
45
50
  * @param el
46
51
  * @param version
47
52
  */
48
- function isExcluding(el, specs, version) {
53
+ function isExcluding(
54
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
55
+ el, specs, version) {
49
56
  /**
50
57
  * The following elements are not exposed via the accessibility API and
51
58
  * user agents MUST NOT include them in the accessibility tree:
@@ -70,7 +77,7 @@ function isExcluding(el, specs, version) {
70
77
  * These exceptions and conditions are documented in the presentation (role)
71
78
  * section.
72
79
  */
73
- if ((0, is_presentational_1.isPresentational)((el.getAttribute('role') || '').split(/\s+/)[0])) {
80
+ if (isPresentational((el.getAttribute('role') ?? '').split(/\s+/)[0])) {
74
81
  return true;
75
82
  }
76
83
  /**
@@ -101,8 +108,8 @@ function isExcluding(el, specs, version) {
101
108
  {
102
109
  let currentEl = el.parentElement;
103
110
  while (currentEl) {
104
- const { role } = (0, get_computed_role_1.getComputedRole)(specs, currentEl, version);
105
- if (role === null || role === void 0 ? void 0 : role.childrenPresentational) {
111
+ const { role } = getComputedRole(specs, currentEl, version);
112
+ if (role?.childrenPresentational) {
106
113
  return true;
107
114
  }
108
115
  currentEl = currentEl.parentElement;
@@ -124,7 +131,9 @@ function isExcluding(el, specs, version) {
124
131
  * @param el
125
132
  * @param version
126
133
  */
127
- function isIncluding(el, specs, version) {
134
+ function isIncluding(
135
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
136
+ el, specs, version) {
128
137
  /**
129
138
  * > **meet any** of the following criteria:
130
139
  */
@@ -149,8 +158,8 @@ function isIncluding(el, specs, version) {
149
158
  * additional guidance on aria-hidden.)
150
159
  */
151
160
  if (el.getAttribute('aria-hidden') !== 'true') {
152
- const globalAria = (0, aria_specs_1.ariaSpecs)(specs, version).props.filter(prop => prop.isGlobal);
153
- 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);
154
163
  // Has an explicit role
155
164
  if (role && !role.isImplicit) {
156
165
  results.push(true);
@@ -171,7 +180,9 @@ function isIncluding(el, specs, version) {
171
180
  // results.push(true);
172
181
  return results.includes(true);
173
182
  }
174
- function hasDisplayNodeOrVisibilityHidden(el) {
183
+ function hasDisplayNodeOrVisibilityHidden(
184
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
185
+ el) {
175
186
  const style = el.getAttribute('style');
176
187
  if (!style) {
177
188
  return false;
@@ -179,3 +190,21 @@ function hasDisplayNodeOrVisibilityHidden(el) {
179
190
  // TODO: Improve accuracy
180
191
  return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
181
192
  }
193
+ function isExposedElement(
194
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
195
+ el, specs) {
196
+ const svgRenderedConditions = specs.def['#contentModels']['#SVGRenderable']?.join(',');
197
+ if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
198
+ return true;
199
+ }
200
+ return isNotMetaOrHiddenHTMLElement(el, specs);
201
+ }
202
+ function isNotMetaOrHiddenHTMLElement(
203
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
204
+ el, specs) {
205
+ const metadataConditions = specs.def['#contentModels']['#metadata']?.join(',');
206
+ if (metadataConditions && el.matches(metadataConditions)) {
207
+ return false;
208
+ }
209
+ return !el.matches('input[type=hidden i]');
210
+ }
@@ -0,0 +1,2 @@
1
+ import type { ARIAVersion, MLMLSpec } from '../types/index.js';
2
+ export declare function matchesContextRole(conditions: readonly string[], ownedEl: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
@@ -0,0 +1,23 @@
1
+ import { getComputedRole } from './get-computed-role.js';
2
+ export function matchesContextRole(conditions,
3
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
4
+ ownedEl, specs, version) {
5
+ return conditions.some(condition => matchesCondition(condition, ownedEl.parentElement, specs, version));
6
+ }
7
+ function matchesCondition(condition,
8
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
+ parentEl, specs, version) {
10
+ const conditions = condition.split(/\s+>\s+/g).reverse();
11
+ while (conditions.length > 0) {
12
+ if (!parentEl) {
13
+ return false;
14
+ }
15
+ const condition = conditions.shift();
16
+ const parentRole = getComputedRole(specs, parentEl, version, true).role;
17
+ if (condition !== parentRole?.name) {
18
+ return false;
19
+ }
20
+ parentEl = parentEl.parentElement;
21
+ }
22
+ return true;
23
+ }
@@ -1,2 +1,2 @@
1
- import type { MLMLSpec } from '../types';
2
- export declare function mayBeFocusable(el: Element, specs: Readonly<MLMLSpec>): boolean;
1
+ import type { MLMLSpec } from '../types/index.js';
2
+ export declare function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
@@ -1,15 +1,14 @@
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(el, specs) {
1
+ import { getSelectorsByContentModelCategory } from '../specs/get-selectors-by-content-model-category.js';
2
+ export function mayBeFocusable(
3
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
4
+ el, specs) {
6
5
  return [
7
6
  /**
8
7
  * Interactive content
9
8
  *
10
9
  * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
11
10
  */
12
- ...(0, get_selectors_by_content_model_category_1.getSelectorsByContentModelCategory)(specs, '#interactive'),
11
+ ...getSelectorsByContentModelCategory(specs, '#interactive'),
13
12
  /**
14
13
  * Interaction
15
14
  *
@@ -19,4 +18,3 @@ function mayBeFocusable(el, specs) {
19
18
  '[contenteditable]:not([contenteditable="false" i])',
20
19
  ].some(selector => el.matches(selector));
21
20
  }
22
- exports.mayBeFocusable = mayBeFocusable;
package/lib/index.d.ts CHANGED
@@ -1,24 +1,28 @@
1
- export * from './dom-traverse/accname-computation';
2
- export * from './dom-traverse/get-attr-specs';
3
- export * from './dom-traverse/get-computed-aria-props';
4
- export * from './dom-traverse/get-computed-role';
5
- export * from './dom-traverse/get-content-model';
6
- export * from './dom-traverse/get-implicit-role';
7
- export * from './dom-traverse/get-permitted-roles';
8
- export * from './dom-traverse/get-spec';
9
- export * from './dom-traverse/has-required-owned-elements';
10
- export * from './dom-traverse/is-exposed';
11
- export * from './dom-traverse/may-be-focusable';
12
- export * from './specs/aria-specs';
13
- export * from './specs/content-model-category-to-tag-names';
14
- export * from './specs/get-role-spec';
15
- export * from './specs/get-spec-by-tag-name';
16
- export * from './specs/is-nothing-content-model';
17
- export * from './specs/is-palpable-elements';
18
- export * from './specs/is-void-element';
19
- export * from './specs/schema-to-spec';
20
- export * from './types';
21
- export * from './types/aria';
22
- export * from './types/attributes';
23
- export * from './types/permitted-structures';
24
- export * from './utils/resolve-namespace';
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/validateAriaVersion.js';
package/lib/index.js CHANGED
@@ -1,27 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./dom-traverse/accname-computation"), exports);
5
- tslib_1.__exportStar(require("./dom-traverse/get-attr-specs"), exports);
6
- tslib_1.__exportStar(require("./dom-traverse/get-computed-aria-props"), exports);
7
- tslib_1.__exportStar(require("./dom-traverse/get-computed-role"), exports);
8
- tslib_1.__exportStar(require("./dom-traverse/get-content-model"), exports);
9
- tslib_1.__exportStar(require("./dom-traverse/get-implicit-role"), exports);
10
- tslib_1.__exportStar(require("./dom-traverse/get-permitted-roles"), exports);
11
- tslib_1.__exportStar(require("./dom-traverse/get-spec"), exports);
12
- tslib_1.__exportStar(require("./dom-traverse/has-required-owned-elements"), exports);
13
- tslib_1.__exportStar(require("./dom-traverse/is-exposed"), exports);
14
- tslib_1.__exportStar(require("./dom-traverse/may-be-focusable"), exports);
15
- tslib_1.__exportStar(require("./specs/aria-specs"), exports);
16
- tslib_1.__exportStar(require("./specs/content-model-category-to-tag-names"), exports);
17
- tslib_1.__exportStar(require("./specs/get-role-spec"), exports);
18
- tslib_1.__exportStar(require("./specs/get-spec-by-tag-name"), exports);
19
- tslib_1.__exportStar(require("./specs/is-nothing-content-model"), exports);
20
- tslib_1.__exportStar(require("./specs/is-palpable-elements"), exports);
21
- tslib_1.__exportStar(require("./specs/is-void-element"), exports);
22
- tslib_1.__exportStar(require("./specs/schema-to-spec"), exports);
23
- tslib_1.__exportStar(require("./types"), exports);
24
- tslib_1.__exportStar(require("./types/aria"), exports);
25
- tslib_1.__exportStar(require("./types/attributes"), exports);
26
- tslib_1.__exportStar(require("./types/permitted-structures"), exports);
27
- tslib_1.__exportStar(require("./utils/resolve-namespace"), 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/validateAriaVersion.js';
@@ -1,6 +1,6 @@
1
- import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function ariaSpecs(specs: Readonly<MLMLSpec>, version: ARIAVersion): {
3
- roles: import("../types").ARIARoleInSchema[];
4
- graphicsRoles: import("../types").ARIARoleInSchema[];
5
- props: 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[];
6
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,3 +1,3 @@
1
- import type { MLMLSpec } from '../types';
2
- import type { Category } from '../types/permitted-structures';
1
+ import type { MLMLSpec } from '../types/index.js';
2
+ import type { Category } from '../types/permitted-structures.js';
3
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,3 +1,4 @@
1
- import type { ARIAVersion, Matches, MLMLSpec } from '../types';
2
- import type { ARIA } from '../types/aria';
3
- export declare function getARIA(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): Omit<ARIA, ARIAVersion | 'conditions'> | null;
1
+ import type { ARIA } from '../types/aria.js';
2
+ import type { ARIAVersion, Matches, MLMLSpec } from '../types/index.js';
3
+ import type { ReadonlyDeep } from 'type-fest';
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;
@@ -21,11 +17,14 @@ function getARIA(specs, localName, namespace, version, matches) {
21
17
  continue;
22
18
  }
23
19
  const condARIA = conditions[cond];
24
- implicitRole = (_a = condARIA.implicitRole) !== null && _a !== void 0 ? _a : implicitRole;
25
- permittedRoles = (_b = condARIA.permittedRoles) !== null && _b !== void 0 ? _b : permittedRoles;
26
- implicitProperties = (_c = condARIA.implicitProperties) !== null && _c !== void 0 ? _c : implicitProperties;
27
- properties = (_d = condARIA.properties) !== null && _d !== void 0 ? _d : properties;
28
- namingProhibited = (_e = condARIA.namingProhibited) !== null && _e !== void 0 ? _e : namingProhibited;
20
+ if (!condARIA) {
21
+ continue;
22
+ }
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;
29
28
  }
30
29
  return {
31
30
  implicitRole,
@@ -35,22 +34,23 @@ function getARIA(specs, localName, namespace, version, matches) {
35
34
  namingProhibited,
36
35
  };
37
36
  }
38
- exports.getARIA = getARIA;
39
37
  function getVersionResolvedARIA(specs, localName, namespace, version) {
40
- var _a;
41
38
  const key = localName + namespace + version;
42
39
  let aria = cache.get(key);
43
40
  if (aria !== undefined) {
44
41
  return aria;
45
42
  }
46
- 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;
47
44
  if (!spec) {
48
45
  cache.set(key, null);
49
46
  return null;
50
47
  }
51
- aria = (0, resolve_version_1.resolveVersion)(spec, version);
52
- if (aria.permittedRoles) {
53
- aria.permittedRoles = optimizePermittedRoles(aria.permittedRoles);
48
+ aria = resolveVersion(spec, version);
49
+ if (aria.permittedRoles !== false) {
50
+ aria = {
51
+ ...aria,
52
+ permittedRoles: optimizePermittedRoles(aria.permittedRoles),
53
+ };
54
54
  }
55
55
  cache.set(key, aria);
56
56
  return aria;
@@ -1,8 +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(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): Attribute[] | null;
3
+ export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): readonly Attribute[] | null;
4
4
  type HasName = {
5
- name: string;
5
+ readonly name: string;
6
6
  };
7
7
  export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
8
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 || undefined);
8
+ const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined);
12
9
  const cache = cacheMap.get(localNameWithNS);
13
10
  if (cache !== undefined) {
14
11
  return cache;
@@ -24,7 +21,7 @@ function getAttrSpecs(localName, namespace, schema) {
24
21
  for (const catName in elSpec.globalAttrs) {
25
22
  // @ts-ignore
26
23
  const catAttrs = elSpec.globalAttrs[catName];
27
- if (!catAttrs) {
24
+ if (catAttrs === false) {
28
25
  continue;
29
26
  }
30
27
  if (typeof catAttrs === 'boolean') {
@@ -66,24 +63,11 @@ function getAttrSpecs(localName, namespace, schema) {
66
63
  const attr = attrs[name];
67
64
  return { name, type: 'Any', ...attr };
68
65
  });
69
- for (const attr of attrList) {
70
- if (!attr.type) {
71
- throw new Error(`The type is empty in the ${attr.name} attribute of the ${localName} element,
72
- 'packages',
73
- '@markuplint',
74
- 'html-spec',
75
- 'src',
76
- 'attributes',
77
- nameWithNS.replace(':', '_') + '.json',
78
- )})`);
79
- }
80
- }
81
66
  attrList.sort(nameCompare);
82
67
  cacheMap.set(localNameWithNS, attrList);
83
68
  return attrList;
84
69
  }
85
- exports.getAttrSpecs = getAttrSpecs;
86
- function nameCompare(a, b) {
70
+ export function nameCompare(a, b) {
87
71
  const nameA = typeof a === 'string' ? a : a.name.toUpperCase();
88
72
  const nameB = typeof b === 'string' ? b : b.name.toUpperCase();
89
73
  if (nameA < nameB) {
@@ -94,4 +78,3 @@ function nameCompare(a, b) {
94
78
  }
95
79
  return 0;
96
80
  }
97
- exports.nameCompare = nameCompare;
@@ -1,2 +1,2 @@
1
- import type { ARIAVersion, Matches, MLMLSpec } from '../types';
2
- export declare function getImplicitRole(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): 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;