@markuplint/ml-spec 3.10.0 → 4.0.0-alpha.1
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.js +2 -5
- package/lib/dom-traverse/accname-computation.js +4 -7
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
- package/lib/dom-traverse/get-attr-specs.js +3 -7
- package/lib/dom-traverse/get-computed-aria-props.d.ts +1 -1
- package/lib/dom-traverse/get-computed-aria-props.js +7 -12
- package/lib/dom-traverse/get-computed-role.d.ts +1 -1
- package/lib/dom-traverse/get-computed-role.js +70 -28
- package/lib/dom-traverse/get-content-model.d.ts +2 -2
- package/lib/dom-traverse/get-content-model.js +5 -10
- package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
- package/lib/dom-traverse/get-explicit-role.js +9 -14
- package/lib/dom-traverse/get-implicit-role.d.ts +2 -2
- package/lib/dom-traverse/get-implicit-role.js +8 -13
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.js +5 -10
- package/lib/dom-traverse/get-permitted-roles.d.ts +1 -1
- package/lib/dom-traverse/get-permitted-roles.js +3 -7
- package/lib/dom-traverse/get-spec.d.ts +1 -1
- package/lib/dom-traverse/get-spec.js +3 -7
- package/lib/dom-traverse/has-required-owned-elements.d.ts +1 -1
- package/lib/dom-traverse/has-required-owned-elements.js +12 -19
- package/lib/dom-traverse/is-exposed.d.ts +1 -1
- package/lib/dom-traverse/is-exposed.js +15 -22
- package/lib/dom-traverse/matches-context-role.d.ts +1 -1
- package/lib/dom-traverse/matches-context-role.js +4 -8
- package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
- package/lib/dom-traverse/may-be-focusable.js +3 -7
- package/lib/index.d.ts +28 -28
- package/lib/index.js +28 -33
- package/lib/specs/aria-specs.d.ts +4 -4
- 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 +2 -2
- package/lib/specs/get-aria.js +10 -16
- package/lib/specs/get-attr-specs.d.ts +1 -1
- package/lib/specs/get-attr-specs.js +4 -9
- 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 +1 -1
- package/lib/specs/get-permitted-roles.js +14 -17
- package/lib/specs/get-role-spec.d.ts +1 -1
- package/lib/specs/get-role-spec.js +10 -14
- package/lib/specs/get-selectors-by-content-model-category.d.ts +2 -2
- package/lib/specs/get-selectors-by-content-model-category.js +2 -6
- package/lib/specs/get-spec-by-tag-name.d.ts +1 -1
- package/lib/specs/get-spec-by-tag-name.js +4 -9
- package/lib/specs/is-nothing-content-model.js +3 -7
- package/lib/specs/is-palpable-elements.d.ts +1 -1
- package/lib/specs/is-palpable-elements.js +5 -10
- package/lib/specs/is-presentational.js +1 -5
- package/lib/specs/is-void-element.js +1 -5
- package/lib/specs/resolve-version.d.ts +2 -2
- package/lib/specs/resolve-version.js +7 -12
- package/lib/specs/schema-to-spec.d.ts +3 -3
- package/lib/specs/schema-to-spec.js +18 -23
- package/lib/types/aria.js +1 -2
- package/lib/types/attributes.d.ts +1 -1
- package/lib/types/attributes.js +1 -2
- package/lib/types/index.d.ts +4 -4
- package/lib/types/index.js +1 -2
- package/lib/types/permitted-structures.js +1 -2
- package/lib/utils/get-ns.js +1 -5
- package/lib/utils/merge-array.js +1 -5
- package/lib/utils/resolve-namespace.js +4 -9
- package/lib/utils/validateAriaVersion.d.ts +1 -1
- package/lib/utils/validateAriaVersion.js +3 -7
- package/package.json +13 -8
- package/test/dom-traverse/accname-computation.spec.js +0 -69
- package/test/dom-traverse/get-computed-aria-props.spec.js +0 -758
- package/test/dom-traverse/get-computed-role.spec.js +0 -294
- package/test/dom-traverse/get-implicit-role.spec.js +0 -40
- package/test/dom-traverse/has-required-owned-elements.spec.js +0 -34
- package/test/dom-traverse/is-exposed.spec.js +0 -70
- package/test/dom-traverse/matches-context-role.spec.js +0 -60
- package/test/specs/get-attr-specs.spec.js +0 -41
- package/test/specs/get-implicit-role.spec.js +0 -79
- package/test/specs/get-permitted-roles.spec.js +0 -418
- package/test/specs/get-role-spec.spec.js +0 -67
- package/test/specs/get-spec-by-tag-name.spec.js +0 -68
- package/test/specs/resolve-version.spec.js +0 -34
- package/test/specs/schema-to-spec.spec.js +0 -61
- package/test/utils/resolve-namespace.spec.js +0 -37
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ARIA_RECOMMENDED_VERSION = exports.ariaVersions = void 0;
|
|
4
|
-
exports.ariaVersions = ['1.1', '1.2', '1.3'];
|
|
5
|
-
exports.ARIA_RECOMMENDED_VERSION = '1.2';
|
|
1
|
+
export const ariaVersions = ['1.1', '1.2', '1.3'];
|
|
2
|
+
export const ARIA_RECOMMENDED_VERSION = '1.2';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const dom_accessibility_api_1 = require("dom-accessibility-api");
|
|
5
|
-
function getAccname(
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { computeAccessibleName } from 'dom-accessibility-api';
|
|
3
|
+
export function getAccname(
|
|
6
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
5
|
el) {
|
|
8
|
-
return
|
|
6
|
+
return computeAccessibleName(el);
|
|
9
7
|
}
|
|
10
|
-
exports.getAccname = getAccname;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import("../types").Attribute[] | null;
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import("../types/index.js").Attribute[] | null;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getAttrSpecs = void 0;
|
|
4
|
-
const get_attr_specs_1 = require("../specs/get-attr-specs");
|
|
5
|
-
function getAttrSpecs(
|
|
1
|
+
import { getAttrSpecs as _getAttrSpecs } from '../specs/get-attr-specs.js';
|
|
2
|
+
export function getAttrSpecs(
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
el, schema) {
|
|
8
|
-
return (
|
|
5
|
+
return _getAttrSpecs(el.localName, el.namespaceURI, schema);
|
|
9
6
|
}
|
|
10
|
-
exports.getAttrSpecs = getAttrSpecs;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const aria_specs_1 = require("../specs/aria-specs");
|
|
5
|
-
const get_computed_role_1 = require("./get-computed-role");
|
|
6
|
-
function getComputedAriaProps(specs,
|
|
1
|
+
import { ariaSpecs as _ariaSpecs } from '../specs/aria-specs.js';
|
|
2
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
export function getComputedAriaProps(specs,
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
5
|
el, version) {
|
|
9
|
-
const ariaSpecs = (
|
|
10
|
-
const { role } =
|
|
6
|
+
const ariaSpecs = _ariaSpecs(specs, version);
|
|
7
|
+
const { role } = getComputedRole(specs, el, version);
|
|
11
8
|
if (!role) {
|
|
12
9
|
return {};
|
|
13
10
|
}
|
|
14
11
|
const props = {};
|
|
15
12
|
role.ownedProperties.forEach(ownedProp => {
|
|
16
|
-
var _a;
|
|
17
13
|
const spec = ariaSpecs.props.find(propSpec => propSpec.name === ownedProp.name);
|
|
18
14
|
if (!spec) {
|
|
19
15
|
return;
|
|
@@ -31,7 +27,7 @@ el, version) {
|
|
|
31
27
|
return;
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
|
-
const equivalentHtmlAttr =
|
|
30
|
+
const equivalentHtmlAttr = spec.equivalentHtmlAttrs?.[0];
|
|
35
31
|
if (equivalentHtmlAttr && el.hasAttribute(equivalentHtmlAttr.htmlAttrName)) {
|
|
36
32
|
const value = equivalentHtmlAttr.value === null
|
|
37
33
|
? el.getAttribute(equivalentHtmlAttr.htmlAttrName)
|
|
@@ -64,7 +60,6 @@ el, version) {
|
|
|
64
60
|
});
|
|
65
61
|
return props;
|
|
66
62
|
}
|
|
67
|
-
exports.getComputedAriaProps = getComputedAriaProps;
|
|
68
63
|
function isValidAriaValue(spec, role, value, enumList) {
|
|
69
64
|
let type = spec.value;
|
|
70
65
|
if (spec.conditionalValue) {
|
|
@@ -74,7 +69,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
74
69
|
}
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
|
-
value = (value
|
|
72
|
+
value = (value ?? '').trim();
|
|
78
73
|
switch (type) {
|
|
79
74
|
case 'string': {
|
|
80
75
|
return true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function getComputedRole(specs: MLMLSpec, el: Element, version: ARIAVersion, assumeSingleNode?: boolean): ComputedRole;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const may_be_focusable_1 = require("./may-be-focusable");
|
|
13
|
-
function getComputedRole(specs,
|
|
1
|
+
import { ariaSpecs } from '../specs/aria-specs.js';
|
|
2
|
+
import { isPresentational } from '../specs/is-presentational.js';
|
|
3
|
+
import { getAccname } from './accname-computation.js';
|
|
4
|
+
import { getAttrSpecs } from './get-attr-specs.js';
|
|
5
|
+
import { getExplicitRole } from './get-explicit-role.js';
|
|
6
|
+
import { getImplicitRole } from './get-implicit-role.js';
|
|
7
|
+
import { getNonPresentationalAncestor } from './get-non-presentational-ancestor.js';
|
|
8
|
+
import { isRequiredOwnedElement } from './has-required-owned-elements.js';
|
|
9
|
+
import { matchesContextRole } from './matches-context-role.js';
|
|
10
|
+
import { mayBeFocusable } from './may-be-focusable.js';
|
|
11
|
+
export function getComputedRole(specs,
|
|
14
12
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
15
13
|
el, version, assumeSingleNode = false) {
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
|
|
14
|
+
const implicitRole = getImplicitRole(specs, el, version);
|
|
15
|
+
const explicitRole = getExplicitRole(specs, el, version);
|
|
19
16
|
const computedRole = explicitRole.role
|
|
20
17
|
? explicitRole
|
|
21
18
|
: {
|
|
@@ -67,7 +64,7 @@ el, version, assumeSingleNode = false) {
|
|
|
67
64
|
errorType: 'NO_OWNER',
|
|
68
65
|
};
|
|
69
66
|
}
|
|
70
|
-
const nonPresentationalAncestor =
|
|
67
|
+
const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
|
|
71
68
|
if (!nonPresentationalAncestor.role) {
|
|
72
69
|
return {
|
|
73
70
|
el,
|
|
@@ -75,7 +72,7 @@ el, version, assumeSingleNode = false) {
|
|
|
75
72
|
errorType: 'NO_OWNER',
|
|
76
73
|
};
|
|
77
74
|
}
|
|
78
|
-
if (!
|
|
75
|
+
if (!matchesContextRole(computedRole.role.requiredContextRole, el, specs, version)) {
|
|
79
76
|
return {
|
|
80
77
|
el,
|
|
81
78
|
role: null,
|
|
@@ -83,7 +80,53 @@ el, version, assumeSingleNode = false) {
|
|
|
83
80
|
};
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
|
-
|
|
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)) {
|
|
87
130
|
return computedRole;
|
|
88
131
|
}
|
|
89
132
|
/**
|
|
@@ -108,7 +151,7 @@ el, version, assumeSingleNode = false) {
|
|
|
108
151
|
* the interactive elements can not specify the presentational role
|
|
109
152
|
* in the previous processing that computes the permitted role (`getExplicitRole`).
|
|
110
153
|
*/
|
|
111
|
-
|
|
154
|
+
mayBeFocusable(el, specs) &&
|
|
112
155
|
/**
|
|
113
156
|
* 2. No disabled
|
|
114
157
|
*/
|
|
@@ -137,13 +180,13 @@ el, version, assumeSingleNode = false) {
|
|
|
137
180
|
* `role=presentation` is to be ignored absolutely.
|
|
138
181
|
*/
|
|
139
182
|
if (explicitRole.role) {
|
|
140
|
-
const nonPresentationalAncestor =
|
|
141
|
-
if (nonPresentationalAncestor.role &&
|
|
183
|
+
const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
|
|
184
|
+
if (nonPresentationalAncestor.role && nonPresentationalAncestor.role?.requiredOwnedElements.length > 0) {
|
|
142
185
|
if (nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
|
|
143
186
|
// const ancestor = nonPresentationalAncestor.el;
|
|
144
187
|
// const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
|
|
145
188
|
// console.log({ nonPresentationalAncestor, ancestorImplicitRole });
|
|
146
|
-
return
|
|
189
|
+
return isRequiredOwnedElement(implicitRole.el, implicitRole.role, expected, specs, version);
|
|
147
190
|
})) {
|
|
148
191
|
return {
|
|
149
192
|
...implicitRole,
|
|
@@ -162,9 +205,9 @@ el, version, assumeSingleNode = false) {
|
|
|
162
205
|
* > unless the presentational role is inherited
|
|
163
206
|
* > and an explicit non-presentational role is applied.
|
|
164
207
|
*/
|
|
165
|
-
const { props } =
|
|
208
|
+
const { props } = ariaSpecs(specs, version);
|
|
166
209
|
for (const attr of Array.from(el.attributes)) {
|
|
167
|
-
if (
|
|
210
|
+
if (props.find(p => p.name === attr.name)?.isGlobal) {
|
|
168
211
|
return {
|
|
169
212
|
...implicitRole,
|
|
170
213
|
errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
|
|
@@ -173,7 +216,6 @@ el, version, assumeSingleNode = false) {
|
|
|
173
216
|
}
|
|
174
217
|
return computedRole;
|
|
175
218
|
}
|
|
176
|
-
exports.getComputedRole = getComputedRole;
|
|
177
219
|
/**
|
|
178
220
|
* The attribute is available in its owner element,
|
|
179
221
|
* it has the attribute.
|
|
@@ -181,8 +223,8 @@ exports.getComputedRole = getComputedRole;
|
|
|
181
223
|
function isEnabledAttr(
|
|
182
224
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
183
225
|
el, specs, attrName) {
|
|
184
|
-
const attrs =
|
|
185
|
-
const attr = attrs
|
|
226
|
+
const attrs = getAttrSpecs(el, specs);
|
|
227
|
+
const attr = attrs?.find(attr => attr.name === attrName);
|
|
186
228
|
return !!attr && el.hasAttribute(attrName);
|
|
187
229
|
}
|
|
188
230
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementSpec } from '../types';
|
|
1
|
+
import type { ElementSpec } from '../types/index.js';
|
|
2
2
|
type Specs = readonly Pick<ElementSpec, 'name' | 'contentModel'>[];
|
|
3
|
-
export declare function getContentModel(el: Element, specs: Specs): boolean | readonly (import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentRequire> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentOptional> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentOneOrMore> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentZeroOrMore> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentChoice> | import("type-fest/source/readonly-deep").ReadonlyObjectDeep<import("../types/permitted-structures").PermittedContentTransparent>)[] | null;
|
|
3
|
+
export declare function getContentModel(el: Element, specs: Specs): boolean | readonly (import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentRequire> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentOptional> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentOneOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentZeroOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentChoice> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentTransparent>)[] | null;
|
|
4
4
|
export {};
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getContentModel = void 0;
|
|
4
|
-
const get_spec_1 = require("./get-spec");
|
|
1
|
+
import { getSpec } from './get-spec.js';
|
|
5
2
|
const cachesBySpecs = new Map();
|
|
6
|
-
function getContentModel(
|
|
3
|
+
export function getContentModel(
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
5
|
el, specs) {
|
|
9
|
-
|
|
10
|
-
const cacheByEl = (_a = cachesBySpecs.get(specs)) !== null && _a !== void 0 ? _a : new Map();
|
|
6
|
+
const cacheByEl = cachesBySpecs.get(specs) ?? new Map();
|
|
11
7
|
const cached = cacheByEl.get(el);
|
|
12
8
|
if (cached !== undefined) {
|
|
13
9
|
return cached;
|
|
14
10
|
}
|
|
15
|
-
const spec =
|
|
11
|
+
const spec = getSpec(el, specs);
|
|
16
12
|
if (!spec) {
|
|
17
13
|
cacheByEl.set(el, null);
|
|
18
14
|
return null;
|
|
19
15
|
}
|
|
20
|
-
const conditions =
|
|
16
|
+
const conditions = spec.contentModel.conditional ?? [];
|
|
21
17
|
for (const cond of conditions) {
|
|
22
18
|
if (el.matches(cond.condition)) {
|
|
23
19
|
cacheByEl.set(el, cond.contents);
|
|
@@ -27,4 +23,3 @@ el, specs) {
|
|
|
27
23
|
cacheByEl.set(el, spec.contentModel.contents);
|
|
28
24
|
return spec.contentModel.contents;
|
|
29
25
|
}
|
|
30
|
-
exports.getContentModel = getContentModel;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function getExplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
6
|
-
const get_permitted_roles_1 = require("./get-permitted-roles");
|
|
7
|
-
function getExplicitRole(specs,
|
|
1
|
+
import { getRoleSpec } from '../specs/get-role-spec.js';
|
|
2
|
+
import { resolveNamespace } from '../utils/resolve-namespace.js';
|
|
3
|
+
import { getPermittedRoles } from './get-permitted-roles.js';
|
|
4
|
+
export function getExplicitRole(specs,
|
|
8
5
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
6
|
el, version) {
|
|
10
|
-
var _a;
|
|
11
7
|
const roleValue = el.getAttribute('role');
|
|
12
|
-
const roleNames =
|
|
13
|
-
const permittedRoles =
|
|
14
|
-
const { namespaceURI } =
|
|
8
|
+
const roleNames = roleValue?.toLowerCase().trim().split(/\s+/g) ?? [];
|
|
9
|
+
const permittedRoles = getPermittedRoles(el, version, specs);
|
|
10
|
+
const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
|
|
15
11
|
let error = 'NO_EXPLICIT';
|
|
16
12
|
/**
|
|
17
13
|
* Resolve from values and **Handling Author Errors**
|
|
@@ -19,7 +15,7 @@ el, version) {
|
|
|
19
15
|
* @see https://w3c.github.io/aria/#document-handling_author-errors
|
|
20
16
|
*/
|
|
21
17
|
for (const roleName of roleNames) {
|
|
22
|
-
const spec =
|
|
18
|
+
const spec = getRoleSpec(specs, roleName, namespaceURI, version);
|
|
23
19
|
/**
|
|
24
20
|
* If `spec` is null, the role DOES NOT EXIST.
|
|
25
21
|
*
|
|
@@ -82,9 +78,8 @@ el, version) {
|
|
|
82
78
|
errorType: error,
|
|
83
79
|
};
|
|
84
80
|
}
|
|
85
|
-
exports.getExplicitRole = getExplicitRole;
|
|
86
81
|
function isLandmarkRole(role) {
|
|
87
|
-
return role
|
|
82
|
+
return role?.superClassRoles.some(su => su.name === 'landmark');
|
|
88
83
|
}
|
|
89
84
|
function isValidLandmarkRole(
|
|
90
85
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
3
|
-
export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("
|
|
3
|
+
export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("../index.js").ImplicitRole;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const get_role_spec_1 = require("../specs/get-role-spec");
|
|
6
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
7
|
-
function getImplicitRole(specs,
|
|
1
|
+
import { getImplicitRole as _getImplicitRole } from '../specs/get-implicit-role.js';
|
|
2
|
+
import { getRoleSpec } from '../specs/get-role-spec.js';
|
|
3
|
+
import { resolveNamespace } from '../utils/resolve-namespace.js';
|
|
4
|
+
export function getImplicitRole(specs,
|
|
8
5
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
6
|
el, version) {
|
|
10
7
|
const implicitRole = getImplicitRoleName(el, version, specs);
|
|
@@ -15,8 +12,8 @@ el, version) {
|
|
|
15
12
|
role: null,
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
|
-
const { namespaceURI } =
|
|
19
|
-
const spec =
|
|
15
|
+
const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
|
|
16
|
+
const spec = getRoleSpec(specs, implicitRole, namespaceURI, version);
|
|
20
17
|
if (!spec) {
|
|
21
18
|
return {
|
|
22
19
|
el,
|
|
@@ -32,10 +29,8 @@ el, version) {
|
|
|
32
29
|
},
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
|
-
|
|
36
|
-
function getImplicitRoleName(
|
|
32
|
+
export function getImplicitRoleName(
|
|
37
33
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
38
34
|
el, version, specs) {
|
|
39
|
-
return (
|
|
35
|
+
return _getImplicitRole(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
40
36
|
}
|
|
41
|
-
exports.getImplicitRoleName = getImplicitRoleName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getNonPresentationalAncestor(el: Element, specs: MLMLSpec, version: ARIAVersion): import("../types").ComputedRole | {
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getNonPresentationalAncestor(el: Element, specs: MLMLSpec, version: ARIAVersion): import("../types/index.js").ComputedRole | {
|
|
3
3
|
el: null;
|
|
4
4
|
role: null;
|
|
5
5
|
};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const is_presentational_1 = require("../specs/is-presentational");
|
|
5
|
-
const get_computed_role_1 = require("./get-computed-role");
|
|
6
|
-
function getNonPresentationalAncestor(
|
|
1
|
+
import { isPresentational } from '../specs/is-presentational.js';
|
|
2
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
export function getNonPresentationalAncestor(
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
5
|
el, specs, version) {
|
|
9
|
-
var _a;
|
|
10
6
|
let ancestor = el.parentElement;
|
|
11
7
|
/**
|
|
12
8
|
* In ARIA 1.1 and 1.2, the role of an element is not affected by the role of its ancestor elements.
|
|
@@ -15,8 +11,8 @@ el, specs, version) {
|
|
|
15
11
|
*/
|
|
16
12
|
const assumeSingleNode = version !== '1.1' && version !== '1.2';
|
|
17
13
|
while (ancestor) {
|
|
18
|
-
const ancestorRole =
|
|
19
|
-
if (!
|
|
14
|
+
const ancestorRole = getComputedRole(specs, ancestor, version, assumeSingleNode);
|
|
15
|
+
if (!isPresentational(ancestorRole.role?.name)) {
|
|
20
16
|
return ancestorRole;
|
|
21
17
|
}
|
|
22
18
|
ancestor = ancestor.parentElement;
|
|
@@ -26,4 +22,3 @@ el, specs, version) {
|
|
|
26
22
|
role: null,
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
|
-
exports.getNonPresentationalAncestor = getNonPresentationalAncestor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: MLMLSpec): readonly {
|
|
3
3
|
readonly name: string;
|
|
4
4
|
readonly deprecated?: boolean | undefined;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getPermittedRoles = void 0;
|
|
4
|
-
const get_permitted_roles_1 = require("../specs/get-permitted-roles");
|
|
5
|
-
function getPermittedRoles(
|
|
1
|
+
import { getPermittedRoles as _getPermittedRoles } from '../specs/get-permitted-roles.js';
|
|
2
|
+
export function getPermittedRoles(
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
el, version, specs) {
|
|
8
|
-
return (
|
|
5
|
+
return _getPermittedRoles(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
9
6
|
}
|
|
10
|
-
exports.getPermittedRoles = getPermittedRoles;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ElementSpec } from '../types';
|
|
1
|
+
import type { ElementSpec } from '../types/index.js';
|
|
2
2
|
export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: readonly Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getSpec = void 0;
|
|
4
|
-
const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
|
|
5
|
-
function getSpec(
|
|
1
|
+
import { getSpecByTagName } from '../specs/get-spec-by-tag-name.js';
|
|
2
|
+
export function getSpec(
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
el, specs) {
|
|
8
|
-
return
|
|
5
|
+
return getSpecByTagName(specs, el.localName, el.namespaceURI);
|
|
9
6
|
}
|
|
10
|
-
exports.getSpec = getSpec;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
3
3
|
export declare function isRequiredOwnedElement(el: Element, role: ComputedRole['role'], query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const get_explicit_role_1 = require("./get-explicit-role");
|
|
7
|
-
const get_implicit_role_1 = require("./get-implicit-role");
|
|
8
|
-
function hasRequiredOwnedElement(
|
|
1
|
+
import { isPresentational } from '../specs/is-presentational.js';
|
|
2
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
import { getExplicitRole } from './get-explicit-role.js';
|
|
4
|
+
import { getImplicitRole } from './get-implicit-role.js';
|
|
5
|
+
export function hasRequiredOwnedElement(
|
|
9
6
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
7
|
el, specs, version) {
|
|
11
8
|
/**
|
|
@@ -20,7 +17,7 @@ el, specs, version) {
|
|
|
20
17
|
/**
|
|
21
18
|
* Otherwise, traverses descendants to find owned elements.
|
|
22
19
|
*/
|
|
23
|
-
const computed =
|
|
20
|
+
const computed = getComputedRole(specs, el, version);
|
|
24
21
|
if (!computed.role || computed.role.requiredOwnedElements.length === 0) {
|
|
25
22
|
return true;
|
|
26
23
|
}
|
|
@@ -33,26 +30,23 @@ el, specs, version) {
|
|
|
33
30
|
}
|
|
34
31
|
return false;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
function isRequiredOwnedElement(
|
|
33
|
+
export function isRequiredOwnedElement(
|
|
38
34
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
39
35
|
el, role, query, specs, version) {
|
|
40
|
-
var _a;
|
|
41
36
|
const [baseRole, owningRole] = query.split(' > ');
|
|
42
|
-
if (
|
|
37
|
+
if (role?.name !== baseRole) {
|
|
43
38
|
return false;
|
|
44
39
|
}
|
|
45
40
|
if (!owningRole) {
|
|
46
41
|
return true;
|
|
47
42
|
}
|
|
48
43
|
for (const owning of getClosestNonPresentationalDescendants(el, specs, version)) {
|
|
49
|
-
if (
|
|
44
|
+
if (owning.role?.name === owningRole) {
|
|
50
45
|
return true;
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
48
|
return false;
|
|
54
49
|
}
|
|
55
|
-
exports.isRequiredOwnedElement = isRequiredOwnedElement;
|
|
56
50
|
/**
|
|
57
51
|
* Gets the list of closest non-presentational descendants.
|
|
58
52
|
* ⚠ THE SPECIFICATION HAS AN ISSUE
|
|
@@ -71,13 +65,12 @@ exports.isRequiredOwnedElement = isRequiredOwnedElement;
|
|
|
71
65
|
function getClosestNonPresentationalDescendants(
|
|
72
66
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
73
67
|
el, specs, version) {
|
|
74
|
-
var _a;
|
|
75
68
|
const owned = [];
|
|
76
69
|
for (const child of Array.from(el.children)) {
|
|
77
|
-
const implicitRole =
|
|
78
|
-
const explicitRole =
|
|
70
|
+
const implicitRole = getImplicitRole(specs, child, version);
|
|
71
|
+
const explicitRole = getExplicitRole(specs, child, version);
|
|
79
72
|
const computed = explicitRole.role ? explicitRole : implicitRole;
|
|
80
|
-
if (
|
|
73
|
+
if (isPresentational(computed.role?.name)) {
|
|
81
74
|
owned.push(...getClosestNonPresentationalDescendants(child, specs, version));
|
|
82
75
|
continue;
|
|
83
76
|
}
|