@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.
- package/lib/constant/aria-version.d.ts +2 -0
- package/lib/constant/aria-version.js +2 -0
- package/lib/dom-traverse/accname-computation.js +6 -7
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
- package/lib/dom-traverse/get-attr-specs.js +5 -7
- package/lib/dom-traverse/get-computed-aria-props.d.ts +2 -2
- package/lib/dom-traverse/get-computed-aria-props.js +10 -13
- package/lib/dom-traverse/get-computed-role.d.ts +2 -2
- package/lib/dom-traverse/get-computed-role.js +104 -31
- package/lib/dom-traverse/get-content-model.d.ts +4 -3
- package/lib/dom-traverse/get-content-model.js +8 -11
- package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
- package/lib/dom-traverse/get-explicit-role.js +14 -14
- package/lib/dom-traverse/get-implicit-role.d.ts +3 -3
- package/lib/dom-traverse/get-implicit-role.js +12 -13
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.js +13 -10
- package/lib/dom-traverse/get-permitted-roles.d.ts +4 -4
- package/lib/dom-traverse/get-permitted-roles.js +5 -7
- package/lib/dom-traverse/get-spec.d.ts +2 -2
- package/lib/dom-traverse/get-spec.js +5 -7
- package/lib/dom-traverse/has-required-owned-elements.d.ts +3 -3
- package/lib/dom-traverse/has-required-owned-elements.js +21 -22
- package/lib/dom-traverse/is-exposed.d.ts +2 -2
- package/lib/dom-traverse/is-exposed.js +47 -18
- package/lib/dom-traverse/matches-context-role.d.ts +2 -0
- package/lib/dom-traverse/matches-context-role.js +23 -0
- package/lib/dom-traverse/may-be-focusable.d.ts +2 -2
- package/lib/dom-traverse/may-be-focusable.js +5 -7
- package/lib/index.d.ts +28 -24
- package/lib/index.js +28 -27
- package/lib/specs/aria-specs.d.ts +5 -5
- package/lib/specs/aria-specs.js +1 -5
- package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
- package/lib/specs/content-model-category-to-tag-names.js +1 -5
- package/lib/specs/get-aria.d.ts +4 -3
- package/lib/specs/get-aria.js +18 -18
- package/lib/specs/get-attr-specs.d.ts +3 -3
- package/lib/specs/get-attr-specs.js +5 -22
- package/lib/specs/get-implicit-role.d.ts +2 -2
- package/lib/specs/get-implicit-role.js +3 -7
- package/lib/specs/get-permitted-roles.d.ts +4 -4
- package/lib/specs/get-permitted-roles.js +29 -28
- package/lib/specs/get-role-spec.d.ts +2 -2
- package/lib/specs/get-role-spec.js +10 -14
- package/lib/specs/get-selectors-by-content-model-category.d.ts +3 -3
- package/lib/specs/get-selectors-by-content-model-category.js +2 -6
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -2
- package/lib/specs/get-spec-by-tag-name.js +4 -8
- package/lib/specs/is-nothing-content-model.js +5 -7
- package/lib/specs/is-palpable-elements.d.ts +4 -4
- package/lib/specs/is-palpable-elements.js +7 -10
- package/lib/specs/is-presentational.js +1 -5
- package/lib/specs/is-void-element.js +3 -5
- package/lib/specs/resolve-version.d.ts +4 -3
- package/lib/specs/resolve-version.js +7 -12
- package/lib/specs/schema-to-spec.d.ts +4 -4
- package/lib/specs/schema-to-spec.js +30 -24
- package/lib/types/aria.d.ts +25 -4
- package/lib/types/aria.js +1 -3
- package/lib/types/attributes.d.ts +3 -4
- package/lib/types/attributes.js +1 -3
- package/lib/types/index.d.ts +93 -92
- package/lib/types/index.js +1 -2
- package/lib/types/permitted-structures.d.ts +6 -2
- package/lib/types/permitted-structures.js +1 -3
- package/lib/utils/get-ns.js +1 -5
- package/lib/utils/merge-array.d.ts +2 -2
- package/lib/utils/merge-array.js +1 -5
- package/lib/utils/resolve-namespace.js +4 -8
- package/lib/utils/validateAriaVersion.d.ts +2 -0
- package/lib/utils/validateAriaVersion.js +4 -0
- package/package.json +20 -10
- package/lib/types/permitted-structres.d.ts +0 -58
- package/lib/types/permitted-structres.js +0 -8
- package/schemas/aria.schema.json +0 -258
- package/schemas/attributes.schema.json +0 -204
- package/schemas/content-models.schema.json +0 -199
- package/schemas/element.schema.json +0 -11
- package/schemas/global-attributes.schema.json +0 -761
- package/src/dom-traverse/accname-computation.spec.ts +0 -69
- package/src/dom-traverse/accname-computation.ts +0 -5
- package/src/dom-traverse/get-attr-specs.ts +0 -8
- package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
- package/src/dom-traverse/get-computed-aria-props.ts +0 -130
- package/src/dom-traverse/get-computed-role.spec.ts +0 -134
- package/src/dom-traverse/get-computed-role.ts +0 -181
- package/src/dom-traverse/get-content-model.ts +0 -32
- package/src/dom-traverse/get-explicit-role.ts +0 -112
- package/src/dom-traverse/get-implicit-role.ts +0 -36
- package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
- package/src/dom-traverse/get-permitted-roles.ts +0 -7
- package/src/dom-traverse/get-spec.ts +0 -7
- package/src/dom-traverse/has-required-owned-elements.spec.ts +0 -36
- package/src/dom-traverse/has-required-owned-elements.ts +0 -85
- package/src/dom-traverse/is-exposed.spec.ts +0 -50
- package/src/dom-traverse/is-exposed.ts +0 -196
- package/src/dom-traverse/may-be-focusable.ts +0 -21
- package/src/index.ts +0 -24
- package/src/specs/aria-specs.ts +0 -6
- package/src/specs/content-model-category-to-tag-names.ts +0 -15
- package/src/specs/get-aria.ts +0 -85
- package/src/specs/get-attr-specs.spec.ts +0 -47
- package/src/specs/get-attr-specs.ts +0 -116
- package/src/specs/get-implicit-role.spec.ts +0 -81
- package/src/specs/get-implicit-role.ts +0 -17
- package/src/specs/get-permitted-roles.spec.ts +0 -420
- package/src/specs/get-permitted-roles.ts +0 -87
- package/src/specs/get-role-spec.spec.ts +0 -67
- package/src/specs/get-role-spec.ts +0 -72
- package/src/specs/get-selectors-by-content-model-category.ts +0 -10
- package/src/specs/get-spec-by-tag-name.spec.ts +0 -68
- package/src/specs/get-spec-by-tag-name.ts +0 -20
- package/src/specs/is-nothing-content-model.ts +0 -9
- package/src/specs/is-palpable-elements.ts +0 -55
- package/src/specs/is-presentational.ts +0 -6
- package/src/specs/is-void-element.ts +0 -22
- package/src/specs/resolve-version.ts +0 -20
- package/src/specs/schema-to-spec.spec.ts +0 -39
- package/src/specs/schema-to-spec.ts +0 -103
- package/src/types/aria.ts +0 -153
- package/src/types/attributes.ts +0 -1524
- package/src/types/index.ts +0 -255
- package/src/types/permitted-structres.ts +0 -100
- package/src/types/permitted-structures.ts +0 -96
- package/src/utils/get-ns.ts +0 -18
- package/src/utils/merge-array.ts +0 -35
- package/src/utils/resolve-namespace.spec.ts +0 -37
- package/src/utils/resolve-namespace.ts +0 -40
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 =
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 (
|
|
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(
|
|
45
|
-
if (
|
|
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(
|
|
68
|
-
|
|
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 =
|
|
72
|
-
const explicitRole =
|
|
70
|
+
const implicitRole = getImplicitRole(specs, child, version);
|
|
71
|
+
const explicitRole = getExplicitRole(specs, child, version);
|
|
73
72
|
const computed = explicitRole.role ? explicitRole : implicitRole;
|
|
74
|
-
if (
|
|
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:
|
|
11
|
+
export declare function isExposed(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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(
|
|
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 (!(
|
|
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(
|
|
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 (
|
|
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 } =
|
|
105
|
-
if (role
|
|
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(
|
|
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 =
|
|
153
|
-
const { role } =
|
|
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(
|
|
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,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:
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
...
|
|
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
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './dom-traverse/
|
|
4
|
-
export * from './dom-traverse/get-
|
|
5
|
-
export * from './dom-traverse/get-
|
|
6
|
-
export * from './dom-traverse/get-
|
|
7
|
-
export * from './dom-traverse/get-
|
|
8
|
-
export * from './dom-traverse/get-
|
|
9
|
-
export * from './dom-traverse/
|
|
10
|
-
export * from './dom-traverse/
|
|
11
|
-
export * from './dom-traverse/
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './specs/
|
|
15
|
-
export * from './specs/
|
|
16
|
-
export * from './specs/
|
|
17
|
-
export * from './specs/
|
|
18
|
-
export * from './specs/
|
|
19
|
-
export * from './specs/
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
22
|
-
export * from './
|
|
23
|
-
export * from './types/
|
|
24
|
-
export * from './
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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:
|
|
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
|
};
|
package/lib/specs/aria-specs.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
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;
|
package/lib/specs/get-aria.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
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;
|
package/lib/specs/get-aria.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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 =
|
|
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 =
|
|
52
|
-
if (aria.permittedRoles) {
|
|
53
|
-
aria
|
|
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
|
-
|
|
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 } =
|
|
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 (
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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;
|