@markuplint/ml-spec 3.4.0 → 3.6.0
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/dom-traverse/accname-computation.js +3 -1
- package/lib/dom-traverse/get-attr-specs.d.ts +1 -1
- package/lib/dom-traverse/get-attr-specs.js +3 -1
- package/lib/dom-traverse/get-computed-aria-props.d.ts +1 -1
- package/lib/dom-traverse/get-computed-aria-props.js +4 -2
- package/lib/dom-traverse/get-computed-role.d.ts +1 -1
- package/lib/dom-traverse/get-computed-role.js +15 -9
- package/lib/dom-traverse/get-content-model.d.ts +26 -3
- package/lib/dom-traverse/get-content-model.js +4 -2
- package/lib/dom-traverse/get-explicit-role.js +8 -3
- package/lib/dom-traverse/get-implicit-role.d.ts +2 -2
- package/lib/dom-traverse/get-implicit-role.js +6 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.js +3 -1
- package/lib/dom-traverse/get-permitted-roles.d.ts +3 -7
- package/lib/dom-traverse/get-permitted-roles.js +3 -1
- package/lib/dom-traverse/get-spec.d.ts +1 -1
- package/lib/dom-traverse/get-spec.js +3 -1
- package/lib/dom-traverse/has-required-owned-elements.d.ts +3 -2
- package/lib/dom-traverse/has-required-owned-elements.js +14 -8
- package/lib/dom-traverse/is-exposed.d.ts +1 -1
- package/lib/dom-traverse/is-exposed.js +21 -8
- package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
- package/lib/dom-traverse/may-be-focusable.js +3 -1
- package/lib/specs/aria-specs.d.ts +4 -4
- package/lib/specs/get-aria.d.ts +2 -7
- package/lib/specs/get-aria.js +5 -2
- package/lib/specs/get-attr-specs.d.ts +2 -2
- package/lib/specs/get-attr-specs.js +2 -14
- package/lib/specs/get-implicit-role.d.ts +1 -1
- package/lib/specs/get-permitted-roles.d.ts +3 -9
- package/lib/specs/get-permitted-roles.js +19 -15
- package/lib/specs/get-role-spec.d.ts +1 -1
- package/lib/specs/get-role-spec.js +2 -2
- package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -4
- package/lib/specs/get-selectors-by-content-model-category.js +1 -1
- package/lib/specs/get-spec-by-tag-name.d.ts +1 -1
- package/lib/specs/get-spec-by-tag-name.js +3 -2
- package/lib/specs/is-nothing-content-model.js +3 -1
- package/lib/specs/is-palpable-elements.d.ts +3 -3
- package/lib/specs/is-palpable-elements.js +6 -4
- package/lib/specs/is-void-element.js +3 -1
- package/lib/specs/resolve-version.d.ts +5 -1
- package/lib/specs/schema-to-spec.d.ts +1 -1
- package/lib/specs/schema-to-spec.js +20 -14
- package/lib/types/aria.d.ts +5 -4
- package/lib/types/index.d.ts +87 -88
- package/lib/utils/merge-array.d.ts +5 -2
- package/lib/utils/resolve-namespace.js +1 -1
- package/package.json +8 -6
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAccname = void 0;
|
|
4
4
|
const dom_accessibility_api_1 = require("dom-accessibility-api");
|
|
5
|
-
function getAccname(
|
|
5
|
+
function getAccname(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
el) {
|
|
6
8
|
return (0, dom_accessibility_api_1.computeAccessibleName)(el);
|
|
7
9
|
}
|
|
8
10
|
exports.getAccname = getAccname;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): import('../types').Attribute[] | null;
|
|
2
|
+
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import('../types').Attribute[] | null;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAttrSpecs = void 0;
|
|
4
4
|
const get_attr_specs_1 = require("../specs/get-attr-specs");
|
|
5
|
-
function getAttrSpecs(
|
|
5
|
+
function getAttrSpecs(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
el, schema) {
|
|
6
8
|
return (0, get_attr_specs_1.getAttrSpecs)(el.localName, el.namespaceURI, schema);
|
|
7
9
|
}
|
|
8
10
|
exports.getAttrSpecs = getAttrSpecs;
|
|
@@ -8,5 +8,5 @@ type ARIAProp = {
|
|
|
8
8
|
from: ARIAPropReferenceType;
|
|
9
9
|
};
|
|
10
10
|
type ARIAPropReferenceType = 'default' | 'html-attr' | 'aria-attr';
|
|
11
|
-
export declare function getComputedAriaProps(specs:
|
|
11
|
+
export declare function getComputedAriaProps(specs: MLMLSpec, el: Element, version: ARIAVersion): ARIAProps;
|
|
12
12
|
export {};
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getComputedAriaProps = void 0;
|
|
4
4
|
const aria_specs_1 = require("../specs/aria-specs");
|
|
5
5
|
const get_computed_role_1 = require("./get-computed-role");
|
|
6
|
-
function getComputedAriaProps(specs,
|
|
6
|
+
function getComputedAriaProps(specs,
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
|
+
el, version) {
|
|
7
9
|
const ariaSpecs = (0, aria_specs_1.ariaSpecs)(specs, version);
|
|
8
10
|
const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
|
|
9
11
|
if (!role) {
|
|
@@ -88,7 +90,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
88
90
|
}
|
|
89
91
|
case 'token':
|
|
90
92
|
case 'token list': {
|
|
91
|
-
if (
|
|
93
|
+
if (enumList.length === 0) {
|
|
92
94
|
throw new Error('Need an enum list in token and token list types');
|
|
93
95
|
}
|
|
94
96
|
return enumList.includes(value.toLowerCase());
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getComputedRole(specs:
|
|
2
|
+
export declare function getComputedRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
@@ -9,8 +9,10 @@ const get_implicit_role_1 = require("./get-implicit-role");
|
|
|
9
9
|
const get_non_presentational_ancestor_1 = require("./get-non-presentational-ancestor");
|
|
10
10
|
const has_required_owned_elements_1 = require("./has-required-owned-elements");
|
|
11
11
|
const may_be_focusable_1 = require("./may-be-focusable");
|
|
12
|
-
function getComputedRole(specs,
|
|
13
|
-
|
|
12
|
+
function getComputedRole(specs,
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
14
|
+
el, version) {
|
|
15
|
+
var _a, _b, _c;
|
|
14
16
|
const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, el, version);
|
|
15
17
|
const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
|
|
16
18
|
const computedRole = explicitRole.role ? explicitRole : implicitRole;
|
|
@@ -39,7 +41,7 @@ function getComputedRole(specs, el, version) {
|
|
|
39
41
|
* However, the presentational role behaves transparently
|
|
40
42
|
* according to the sample code in WAI-ARIA specification.
|
|
41
43
|
*/
|
|
42
|
-
if (
|
|
44
|
+
if (computedRole.role && computedRole.role.requiredContextRole.length > 0) {
|
|
43
45
|
const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
|
|
44
46
|
if (!nonPresentationalAncestor.role) {
|
|
45
47
|
return {
|
|
@@ -48,7 +50,7 @@ function getComputedRole(specs, el, version) {
|
|
|
48
50
|
errorType: 'NO_OWNER',
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
|
-
if (!((
|
|
53
|
+
if (!((_a = computedRole.role) === null || _a === void 0 ? void 0 : _a.requiredContextRole.includes(nonPresentationalAncestor.role.name))) {
|
|
52
54
|
return {
|
|
53
55
|
el,
|
|
54
56
|
role: null,
|
|
@@ -111,12 +113,12 @@ function getComputedRole(specs, el, version) {
|
|
|
111
113
|
*/
|
|
112
114
|
if (explicitRole.role) {
|
|
113
115
|
const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
|
|
114
|
-
if ((
|
|
116
|
+
if (nonPresentationalAncestor.role && ((_b = nonPresentationalAncestor.role) === null || _b === void 0 ? void 0 : _b.requiredOwnedElements.length) > 0) {
|
|
115
117
|
if (nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
|
|
116
118
|
// const ancestor = nonPresentationalAncestor.el;
|
|
117
119
|
// const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
|
|
118
120
|
// console.log({ nonPresentationalAncestor, ancestorImplicitRole });
|
|
119
|
-
return (0, has_required_owned_elements_1.isRequiredOwnedElement)(implicitRole, expected, specs, version);
|
|
121
|
+
return (0, has_required_owned_elements_1.isRequiredOwnedElement)(implicitRole.el, implicitRole.role, expected, specs, version);
|
|
120
122
|
})) {
|
|
121
123
|
return {
|
|
122
124
|
...implicitRole,
|
|
@@ -137,7 +139,7 @@ function getComputedRole(specs, el, version) {
|
|
|
137
139
|
*/
|
|
138
140
|
const { props } = (0, aria_specs_1.ariaSpecs)(specs, version);
|
|
139
141
|
for (const attr of Array.from(el.attributes)) {
|
|
140
|
-
if ((
|
|
142
|
+
if ((_c = props.find(p => p.name === attr.name)) === null || _c === void 0 ? void 0 : _c.isGlobal) {
|
|
141
143
|
return {
|
|
142
144
|
...implicitRole,
|
|
143
145
|
errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
|
|
@@ -151,7 +153,9 @@ exports.getComputedRole = getComputedRole;
|
|
|
151
153
|
* The attribute is available in its owner element,
|
|
152
154
|
* it has the attribute.
|
|
153
155
|
*/
|
|
154
|
-
function isEnabledAttr(
|
|
156
|
+
function isEnabledAttr(
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
158
|
+
el, specs, attrName) {
|
|
155
159
|
const attrs = (0, get_attr_specs_1.getAttrSpecs)(el, specs);
|
|
156
160
|
const attr = attrs === null || attrs === void 0 ? void 0 : attrs.find(attr => attr.name === attrName);
|
|
157
161
|
return !!attr && el.hasAttribute(attrName);
|
|
@@ -159,7 +163,9 @@ function isEnabledAttr(el, specs, attrName) {
|
|
|
159
163
|
/**
|
|
160
164
|
* Determines whether some ancestors match the condition that the specified callback function.
|
|
161
165
|
*/
|
|
162
|
-
function someAncestors(
|
|
166
|
+
function someAncestors(
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
168
|
+
el, predicate) {
|
|
163
169
|
const list = [];
|
|
164
170
|
let current = el;
|
|
165
171
|
while (current) {
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
|
|
2
|
+
type Specs = readonly Pick<ElementSpec, 'name' | 'contentModel'>[];
|
|
3
3
|
export declare function getContentModel(
|
|
4
4
|
el: Element,
|
|
5
|
-
specs:
|
|
6
|
-
):
|
|
5
|
+
specs: Specs,
|
|
6
|
+
):
|
|
7
|
+
| boolean
|
|
8
|
+
| readonly (
|
|
9
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
10
|
+
import('../types/permitted-structures').PermittedContentRequire
|
|
11
|
+
>
|
|
12
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
13
|
+
import('../types/permitted-structures').PermittedContentOptional
|
|
14
|
+
>
|
|
15
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
16
|
+
import('../types/permitted-structures').PermittedContentOneOrMore
|
|
17
|
+
>
|
|
18
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
19
|
+
import('../types/permitted-structures').PermittedContentZeroOrMore
|
|
20
|
+
>
|
|
21
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
22
|
+
import('../types/permitted-structures').PermittedContentChoice
|
|
23
|
+
>
|
|
24
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
25
|
+
import('../types/permitted-structures').PermittedContentTransparent
|
|
26
|
+
>
|
|
27
|
+
)[]
|
|
28
|
+
| null;
|
|
29
|
+
export {};
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getContentModel = void 0;
|
|
4
4
|
const get_spec_1 = require("./get-spec");
|
|
5
5
|
const cachesBySpecs = new Map();
|
|
6
|
-
function getContentModel(
|
|
6
|
+
function getContentModel(
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
|
+
el, specs) {
|
|
7
9
|
var _a, _b;
|
|
8
10
|
const cacheByEl = (_a = cachesBySpecs.get(specs)) !== null && _a !== void 0 ? _a : new Map();
|
|
9
11
|
const cached = cacheByEl.get(el);
|
|
10
|
-
if (cached) {
|
|
12
|
+
if (cached !== undefined) {
|
|
11
13
|
return cached;
|
|
12
14
|
}
|
|
13
15
|
const spec = (0, get_spec_1.getSpec)(el, specs);
|
|
@@ -4,9 +4,12 @@ exports.getExplicitRole = void 0;
|
|
|
4
4
|
const get_role_spec_1 = require("../specs/get-role-spec");
|
|
5
5
|
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
6
6
|
const get_permitted_roles_1 = require("./get-permitted-roles");
|
|
7
|
-
function getExplicitRole(specs,
|
|
7
|
+
function getExplicitRole(specs,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
|
+
el, version) {
|
|
10
|
+
var _a;
|
|
8
11
|
const roleValue = el.getAttribute('role');
|
|
9
|
-
const roleNames = (roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g))
|
|
12
|
+
const roleNames = (_a = roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g)) !== null && _a !== void 0 ? _a : [];
|
|
10
13
|
const permittedRoles = (0, get_permitted_roles_1.getPermittedRoles)(el, version, specs);
|
|
11
14
|
const { namespaceURI } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
|
|
12
15
|
let error = 'NO_EXPLICIT';
|
|
@@ -83,7 +86,9 @@ exports.getExplicitRole = getExplicitRole;
|
|
|
83
86
|
function isLandmarkRole(role) {
|
|
84
87
|
return role === null || role === void 0 ? void 0 : role.superClassRoles.some(su => su.name === 'landmark');
|
|
85
88
|
}
|
|
86
|
-
function isValidLandmarkRole(
|
|
89
|
+
function isValidLandmarkRole(
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
91
|
+
el, role) {
|
|
87
92
|
if (!role.accessibleNameRequired) {
|
|
88
93
|
return true;
|
|
89
94
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(specs:
|
|
2
|
+
export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
3
3
|
export declare function getImplicitRoleName(
|
|
4
4
|
el: Element,
|
|
5
5
|
version: ARIAVersion,
|
|
6
|
-
specs:
|
|
6
|
+
specs: MLMLSpec,
|
|
7
7
|
): import('..').ImplicitRole;
|
|
@@ -4,7 +4,9 @@ exports.getImplicitRoleName = exports.getImplicitRole = void 0;
|
|
|
4
4
|
const get_implicit_role_1 = require("../specs/get-implicit-role");
|
|
5
5
|
const get_role_spec_1 = require("../specs/get-role-spec");
|
|
6
6
|
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
7
|
-
function getImplicitRole(specs,
|
|
7
|
+
function getImplicitRole(specs,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
|
+
el, version) {
|
|
8
10
|
const implicitRole = getImplicitRoleName(el, version, specs);
|
|
9
11
|
if (implicitRole === false) {
|
|
10
12
|
// No Corresponding Role
|
|
@@ -31,7 +33,9 @@ function getImplicitRole(specs, el, version) {
|
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
exports.getImplicitRole = getImplicitRole;
|
|
34
|
-
function getImplicitRoleName(
|
|
36
|
+
function getImplicitRoleName(
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
38
|
+
el, version, specs) {
|
|
35
39
|
return (0, get_implicit_role_1.getImplicitRole)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
36
40
|
}
|
|
37
41
|
exports.getImplicitRoleName = getImplicitRoleName;
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getNonPresentationalAncestor = void 0;
|
|
4
4
|
const is_presentational_1 = require("../specs/is-presentational");
|
|
5
5
|
const get_computed_role_1 = require("./get-computed-role");
|
|
6
|
-
function getNonPresentationalAncestor(
|
|
6
|
+
function getNonPresentationalAncestor(
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
|
+
el, specs, version) {
|
|
7
9
|
var _a;
|
|
8
10
|
let ancestor = el.parentElement;
|
|
9
11
|
while (ancestor) {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getPermittedRoles(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
specs: Readonly<MLMLSpec>,
|
|
6
|
-
): {
|
|
7
|
-
name: string;
|
|
8
|
-
deprecated?: boolean | undefined;
|
|
2
|
+
export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: MLMLSpec): readonly {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly deprecated?: boolean | undefined;
|
|
9
5
|
}[];
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPermittedRoles = void 0;
|
|
4
4
|
const get_permitted_roles_1 = require("../specs/get-permitted-roles");
|
|
5
|
-
function getPermittedRoles(
|
|
5
|
+
function getPermittedRoles(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
el, version, specs) {
|
|
6
8
|
return (0, get_permitted_roles_1.getPermittedRoles)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
7
9
|
}
|
|
8
10
|
exports.getPermittedRoles = getPermittedRoles;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSpec = void 0;
|
|
4
4
|
const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
|
|
5
|
-
function getSpec(
|
|
5
|
+
function getSpec(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
el, specs) {
|
|
6
8
|
return (0, get_spec_by_tag_name_1.getSpecByTagName)(specs, el.localName, el.namespaceURI);
|
|
7
9
|
}
|
|
8
10
|
exports.getSpec = getSpec;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function hasRequiredOwnedElement(el: Element, specs:
|
|
2
|
+
export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
3
3
|
export declare function isRequiredOwnedElement(
|
|
4
|
-
|
|
4
|
+
el: Element,
|
|
5
|
+
role: ComputedRole['role'],
|
|
5
6
|
query: string,
|
|
6
7
|
specs: MLMLSpec,
|
|
7
8
|
version: ARIAVersion,
|
|
@@ -5,7 +5,9 @@ const is_presentational_1 = require("../specs/is-presentational");
|
|
|
5
5
|
const get_computed_role_1 = require("./get-computed-role");
|
|
6
6
|
const get_explicit_role_1 = require("./get-explicit-role");
|
|
7
7
|
const get_implicit_role_1 = require("./get-implicit-role");
|
|
8
|
-
function hasRequiredOwnedElement(
|
|
8
|
+
function hasRequiredOwnedElement(
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
|
+
el, specs, version) {
|
|
9
11
|
/**
|
|
10
12
|
* The element has aria-owns which means it may have owned elements.
|
|
11
13
|
*
|
|
@@ -24,7 +26,7 @@ function hasRequiredOwnedElement(el, specs, version) {
|
|
|
24
26
|
}
|
|
25
27
|
for (const expectRole of computed.role.requiredOwnedElements) {
|
|
26
28
|
for (const owned of getClosestNonPresentationalDescendants(el, specs, version)) {
|
|
27
|
-
if (isRequiredOwnedElement(owned, expectRole, specs, version)) {
|
|
29
|
+
if (isRequiredOwnedElement(owned.el, owned.role, expectRole, specs, version)) {
|
|
28
30
|
return true;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
@@ -32,17 +34,19 @@ function hasRequiredOwnedElement(el, specs, version) {
|
|
|
32
34
|
return false;
|
|
33
35
|
}
|
|
34
36
|
exports.hasRequiredOwnedElement = hasRequiredOwnedElement;
|
|
35
|
-
function isRequiredOwnedElement(
|
|
36
|
-
|
|
37
|
+
function isRequiredOwnedElement(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
39
|
+
el, role, query, specs, version) {
|
|
40
|
+
var _a;
|
|
37
41
|
const [baseRole, owningRole] = query.split(' > ');
|
|
38
|
-
if ((
|
|
42
|
+
if ((role === null || role === void 0 ? void 0 : role.name) !== baseRole) {
|
|
39
43
|
return false;
|
|
40
44
|
}
|
|
41
45
|
if (!owningRole) {
|
|
42
46
|
return true;
|
|
43
47
|
}
|
|
44
|
-
for (const owning of getClosestNonPresentationalDescendants(
|
|
45
|
-
if (((
|
|
48
|
+
for (const owning of getClosestNonPresentationalDescendants(el, specs, version)) {
|
|
49
|
+
if (((_a = owning.role) === null || _a === void 0 ? void 0 : _a.name) === owningRole) {
|
|
46
50
|
return true;
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -64,7 +68,9 @@ exports.isRequiredOwnedElement = isRequiredOwnedElement;
|
|
|
64
68
|
* However, the presentational role behaves transparently
|
|
65
69
|
* according to the sample code in WAI-ARIA specification.
|
|
66
70
|
*/
|
|
67
|
-
function getClosestNonPresentationalDescendants(
|
|
71
|
+
function getClosestNonPresentationalDescendants(
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
73
|
+
el, specs, version) {
|
|
68
74
|
var _a;
|
|
69
75
|
const owned = [];
|
|
70
76
|
for (const child of Array.from(el.children)) {
|
|
@@ -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;
|
|
@@ -15,7 +15,9 @@ const get_computed_role_1 = require("./get-computed-role");
|
|
|
15
15
|
* @param el
|
|
16
16
|
* @param version
|
|
17
17
|
*/
|
|
18
|
-
function isExposed(
|
|
18
|
+
function isExposed(
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
20
|
+
el, specs, version) {
|
|
19
21
|
// According to WAI-ARIA
|
|
20
22
|
if (isExcluding(el, specs, version)) {
|
|
21
23
|
return false;
|
|
@@ -23,7 +25,7 @@ function isExposed(el, specs, version) {
|
|
|
23
25
|
// Return true if the element is unknown, deprecated, or obsolete.
|
|
24
26
|
const { localName, namespace } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
|
|
25
27
|
const spec = (0, get_spec_by_tag_name_1.getSpecByTagName)(specs.specs, localName, namespace);
|
|
26
|
-
if (!spec || spec.deprecated || spec.obsolete) {
|
|
28
|
+
if (!spec || spec.deprecated || spec.obsolete != null) {
|
|
27
29
|
return true;
|
|
28
30
|
}
|
|
29
31
|
// According to HTML and SVG Specs with **the author's interpretation**
|
|
@@ -52,7 +54,10 @@ exports.isExposed = isExposed;
|
|
|
52
54
|
* @param el
|
|
53
55
|
* @param version
|
|
54
56
|
*/
|
|
55
|
-
function isExcluding(
|
|
57
|
+
function isExcluding(
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
59
|
+
el, specs, version) {
|
|
60
|
+
var _a;
|
|
56
61
|
/**
|
|
57
62
|
* The following elements are not exposed via the accessibility API and
|
|
58
63
|
* user agents MUST NOT include them in the accessibility tree:
|
|
@@ -77,7 +82,7 @@ function isExcluding(el, specs, version) {
|
|
|
77
82
|
* These exceptions and conditions are documented in the presentation (role)
|
|
78
83
|
* section.
|
|
79
84
|
*/
|
|
80
|
-
if ((0, is_presentational_1.isPresentational)((el.getAttribute('role')
|
|
85
|
+
if ((0, is_presentational_1.isPresentational)(((_a = el.getAttribute('role')) !== null && _a !== void 0 ? _a : '').split(/\s+/)[0])) {
|
|
81
86
|
return true;
|
|
82
87
|
}
|
|
83
88
|
/**
|
|
@@ -131,7 +136,9 @@ function isExcluding(el, specs, version) {
|
|
|
131
136
|
* @param el
|
|
132
137
|
* @param version
|
|
133
138
|
*/
|
|
134
|
-
function isIncluding(
|
|
139
|
+
function isIncluding(
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
141
|
+
el, specs, version) {
|
|
135
142
|
/**
|
|
136
143
|
* > **meet any** of the following criteria:
|
|
137
144
|
*/
|
|
@@ -178,7 +185,9 @@ function isIncluding(el, specs, version) {
|
|
|
178
185
|
// results.push(true);
|
|
179
186
|
return results.includes(true);
|
|
180
187
|
}
|
|
181
|
-
function hasDisplayNodeOrVisibilityHidden(
|
|
188
|
+
function hasDisplayNodeOrVisibilityHidden(
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
190
|
+
el) {
|
|
182
191
|
const style = el.getAttribute('style');
|
|
183
192
|
if (!style) {
|
|
184
193
|
return false;
|
|
@@ -186,7 +195,9 @@ function hasDisplayNodeOrVisibilityHidden(el) {
|
|
|
186
195
|
// TODO: Improve accuracy
|
|
187
196
|
return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
|
|
188
197
|
}
|
|
189
|
-
function isExposedElement(
|
|
198
|
+
function isExposedElement(
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
200
|
+
el, specs) {
|
|
190
201
|
var _a;
|
|
191
202
|
const svgRenderedConditions = (_a = specs.def['#contentModels']['#SVGRenderable']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
192
203
|
if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
|
|
@@ -194,7 +205,9 @@ function isExposedElement(el, specs) {
|
|
|
194
205
|
}
|
|
195
206
|
return isNotMetaOrHiddenHTMLElement(el, specs);
|
|
196
207
|
}
|
|
197
|
-
function isNotMetaOrHiddenHTMLElement(
|
|
208
|
+
function isNotMetaOrHiddenHTMLElement(
|
|
209
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
210
|
+
el, specs) {
|
|
198
211
|
var _a;
|
|
199
212
|
const metadataConditions = (_a = specs.def['#contentModels']['#metadata']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
200
213
|
if (metadataConditions && el.matches(metadataConditions)) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function mayBeFocusable(el: Element, specs:
|
|
2
|
+
export declare function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mayBeFocusable = void 0;
|
|
4
4
|
const get_selectors_by_content_model_category_1 = require("../specs/get-selectors-by-content-model-category");
|
|
5
|
-
function mayBeFocusable(
|
|
5
|
+
function mayBeFocusable(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
el, specs) {
|
|
6
8
|
return [
|
|
7
9
|
/**
|
|
8
10
|
* Interactive content
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
2
|
export declare function ariaSpecs(
|
|
3
|
-
specs:
|
|
3
|
+
specs: MLMLSpec,
|
|
4
4
|
version: ARIAVersion,
|
|
5
5
|
): {
|
|
6
|
-
roles: import('../types').ARIARoleInSchema[];
|
|
7
|
-
graphicsRoles: import('../types').ARIARoleInSchema[];
|
|
8
|
-
props: import('../types').ARIAProperty[];
|
|
6
|
+
readonly roles: readonly import('../types').ARIARoleInSchema[];
|
|
7
|
+
readonly graphicsRoles: readonly import('../types').ARIARoleInSchema[];
|
|
8
|
+
readonly props: readonly import('../types').ARIAProperty[];
|
|
9
9
|
};
|
package/lib/specs/get-aria.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
2
|
import type { ARIA } from '../types/aria';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
localName: string,
|
|
6
|
-
namespace: string | null,
|
|
7
|
-
version: ARIAVersion,
|
|
8
|
-
matches: Matches,
|
|
9
|
-
): Omit<ARIA, ARIAVersion | 'conditions'> | null;
|
|
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
|
@@ -52,8 +52,11 @@ function getVersionResolvedARIA(specs, localName, namespace, version) {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
aria = (0, resolve_version_1.resolveVersion)(spec, version);
|
|
55
|
-
if (aria.permittedRoles) {
|
|
56
|
-
aria
|
|
55
|
+
if (aria.permittedRoles !== false) {
|
|
56
|
+
aria = {
|
|
57
|
+
...aria,
|
|
58
|
+
permittedRoles: optimizePermittedRoles(aria.permittedRoles),
|
|
59
|
+
};
|
|
57
60
|
}
|
|
58
61
|
cache.set(key, aria);
|
|
59
62
|
return aria;
|
|
@@ -4,9 +4,9 @@ export declare function getAttrSpecs(
|
|
|
4
4
|
localName: string,
|
|
5
5
|
namespace: NamespaceURI | null,
|
|
6
6
|
schema: MLMLSpec,
|
|
7
|
-
): Attribute[] | null;
|
|
7
|
+
): readonly Attribute[] | null;
|
|
8
8
|
type HasName = {
|
|
9
|
-
name: string;
|
|
9
|
+
readonly name: string;
|
|
10
10
|
};
|
|
11
11
|
export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
|
|
12
12
|
export {};
|
|
@@ -8,7 +8,7 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
8
8
|
if (!schemaCache.has(schema)) {
|
|
9
9
|
cacheMap.clear();
|
|
10
10
|
}
|
|
11
|
-
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace
|
|
11
|
+
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace !== null && namespace !== void 0 ? namespace : undefined);
|
|
12
12
|
const cache = cacheMap.get(localNameWithNS);
|
|
13
13
|
if (cache !== undefined) {
|
|
14
14
|
return cache;
|
|
@@ -24,7 +24,7 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
24
24
|
for (const catName in elSpec.globalAttrs) {
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
const catAttrs = elSpec.globalAttrs[catName];
|
|
27
|
-
if (
|
|
27
|
+
if (catAttrs === false) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
30
|
if (typeof catAttrs === 'boolean') {
|
|
@@ -66,18 +66,6 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
66
66
|
const attr = attrs[name];
|
|
67
67
|
return { name, type: 'Any', ...attr };
|
|
68
68
|
});
|
|
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
69
|
attrList.sort(nameCompare);
|
|
82
70
|
cacheMap.set(localNameWithNS, attrList);
|
|
83
71
|
return attrList;
|
|
@@ -6,13 +6,7 @@ import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
|
6
6
|
* - If `true`, this mean is "Any".
|
|
7
7
|
* - If `false`, this mean is "No".
|
|
8
8
|
*/
|
|
9
|
-
export declare function getPermittedRoles(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
namespace: string | null,
|
|
13
|
-
version: ARIAVersion,
|
|
14
|
-
matches: Matches,
|
|
15
|
-
): {
|
|
16
|
-
name: string;
|
|
17
|
-
deprecated?: boolean;
|
|
9
|
+
export declare function getPermittedRoles(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): readonly {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly deprecated?: boolean;
|
|
18
12
|
}[];
|