@markuplint/ml-spec 3.4.0 → 3.5.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 +6 -6
- package/lib/dom-traverse/get-computed-aria-props.js +3 -1
- package/lib/dom-traverse/get-computed-role.d.ts +1 -1
- package/lib/dom-traverse/get-computed-role.js +10 -4
- package/lib/dom-traverse/get-content-model.d.ts +3 -5
- package/lib/dom-traverse/get-content-model.js +3 -1
- package/lib/dom-traverse/get-explicit-role.js +6 -2
- package/lib/dom-traverse/get-implicit-role.d.ts +2 -6
- package/lib/dom-traverse/get-implicit-role.js +6 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +4 -10
- 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 -4
- package/lib/dom-traverse/get-spec.js +3 -1
- package/lib/dom-traverse/has-required-owned-elements.d.ts +2 -7
- 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 +18 -6
- 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 -7
- package/lib/specs/content-model-category-to-tag-names.d.ts +1 -4
- package/lib/specs/get-aria.d.ts +2 -7
- package/lib/specs/get-aria.js +4 -1
- package/lib/specs/get-attr-specs.d.ts +2 -6
- package/lib/specs/get-implicit-role.d.ts +1 -7
- package/lib/specs/get-permitted-roles.d.ts +3 -9
- package/lib/specs/get-permitted-roles.js +15 -11
- package/lib/specs/get-role-spec.d.ts +3 -10
- package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -4
- package/lib/specs/get-spec-by-tag-name.d.ts +1 -5
- package/lib/specs/is-nothing-content-model.js +3 -1
- package/lib/specs/is-palpable-elements.d.ts +4 -8
- package/lib/specs/is-palpable-elements.js +3 -1
- package/lib/specs/is-void-element.js +3 -1
- package/lib/specs/resolve-version.d.ts +2 -1
- package/lib/specs/schema-to-spec.d.ts +3 -3
- package/lib/specs/schema-to-spec.js +20 -14
- package/lib/types/aria.d.ts +115 -128
- package/lib/types/attributes.d.ts +110 -1490
- package/lib/types/index.d.ts +147 -176
- package/lib/types/permitted-structures.d.ts +35 -74
- package/lib/utils/merge-array.d.ts +4 -6
- package/lib/utils/resolve-namespace.d.ts +4 -4
- 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(
|
|
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;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
2
|
type ARIAProps = Record<string, ARIAProp>;
|
|
3
3
|
type ARIAProp = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
name: string;
|
|
5
|
+
value: string | undefined;
|
|
6
|
+
required: boolean;
|
|
7
|
+
deprecated: boolean;
|
|
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) {
|
|
@@ -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,7 +9,9 @@ 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,
|
|
12
|
+
function getComputedRole(specs,
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
14
|
+
el, version) {
|
|
13
15
|
var _a, _b, _c, _d;
|
|
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);
|
|
@@ -116,7 +118,7 @@ function getComputedRole(specs, el, version) {
|
|
|
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,
|
|
@@ -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,4 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
|
|
3
|
-
export declare function getContentModel(
|
|
4
|
-
|
|
5
|
-
specs: Pick<ElementSpec, 'name' | 'contentModel'>[],
|
|
6
|
-
): boolean | PermittedContentPattern[] | null;
|
|
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;
|
|
4
|
+
export {};
|
|
@@ -3,7 +3,9 @@ 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);
|
|
@@ -4,7 +4,9 @@ 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) {
|
|
8
10
|
const roleValue = el.getAttribute('role');
|
|
9
11
|
const roleNames = (roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g)) || [];
|
|
10
12
|
const permittedRoles = (0, get_permitted_roles_1.getPermittedRoles)(el, version, specs);
|
|
@@ -83,7 +85,9 @@ exports.getExplicitRole = getExplicitRole;
|
|
|
83
85
|
function isLandmarkRole(role) {
|
|
84
86
|
return role === null || role === void 0 ? void 0 : role.superClassRoles.some(su => su.name === 'landmark');
|
|
85
87
|
}
|
|
86
|
-
function isValidLandmarkRole(
|
|
88
|
+
function isValidLandmarkRole(
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
90
|
+
el, role) {
|
|
87
91
|
if (!role.accessibleNameRequired) {
|
|
88
92
|
return true;
|
|
89
93
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(specs:
|
|
3
|
-
export declare function getImplicitRoleName(
|
|
4
|
-
el: Element,
|
|
5
|
-
version: ARIAVersion,
|
|
6
|
-
specs: Readonly<MLMLSpec>,
|
|
7
|
-
): import('..').ImplicitRole;
|
|
2
|
+
export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
3
|
+
export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): 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;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getNonPresentationalAncestor(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
):
|
|
7
|
-
| import('../types').ComputedRole
|
|
8
|
-
| {
|
|
9
|
-
el: null;
|
|
10
|
-
role: null;
|
|
11
|
-
};
|
|
2
|
+
export declare function getNonPresentationalAncestor(el: Element, specs: MLMLSpec, version: ARIAVersion): import("../types").ComputedRole | {
|
|
3
|
+
el: null;
|
|
4
|
+
role: null;
|
|
5
|
+
};
|
|
@@ -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;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpec<K extends keyof ElementSpec>(
|
|
3
|
-
el: Element,
|
|
4
|
-
specs: Pick<ElementSpec, 'name' | K>[],
|
|
5
|
-
): Pick<ElementSpec, 'name' | K> | null;
|
|
2
|
+
export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: readonly Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
|
|
@@ -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,8 +1,3 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function hasRequiredOwnedElement(el: Element, specs:
|
|
3
|
-
export declare function isRequiredOwnedElement(
|
|
4
|
-
owned: ComputedRole,
|
|
5
|
-
query: string,
|
|
6
|
-
specs: MLMLSpec,
|
|
7
|
-
version: ARIAVersion,
|
|
8
|
-
): boolean;
|
|
2
|
+
export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
3
|
+
export declare function isRequiredOwnedElement(el: Element, role: ComputedRole['role'], query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -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;
|
|
@@ -52,7 +54,9 @@ 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) {
|
|
56
60
|
/**
|
|
57
61
|
* The following elements are not exposed via the accessibility API and
|
|
58
62
|
* user agents MUST NOT include them in the accessibility tree:
|
|
@@ -131,7 +135,9 @@ function isExcluding(el, specs, version) {
|
|
|
131
135
|
* @param el
|
|
132
136
|
* @param version
|
|
133
137
|
*/
|
|
134
|
-
function isIncluding(
|
|
138
|
+
function isIncluding(
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
140
|
+
el, specs, version) {
|
|
135
141
|
/**
|
|
136
142
|
* > **meet any** of the following criteria:
|
|
137
143
|
*/
|
|
@@ -178,7 +184,9 @@ function isIncluding(el, specs, version) {
|
|
|
178
184
|
// results.push(true);
|
|
179
185
|
return results.includes(true);
|
|
180
186
|
}
|
|
181
|
-
function hasDisplayNodeOrVisibilityHidden(
|
|
187
|
+
function hasDisplayNodeOrVisibilityHidden(
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
189
|
+
el) {
|
|
182
190
|
const style = el.getAttribute('style');
|
|
183
191
|
if (!style) {
|
|
184
192
|
return false;
|
|
@@ -186,7 +194,9 @@ function hasDisplayNodeOrVisibilityHidden(el) {
|
|
|
186
194
|
// TODO: Improve accuracy
|
|
187
195
|
return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
|
|
188
196
|
}
|
|
189
|
-
function isExposedElement(
|
|
197
|
+
function isExposedElement(
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
199
|
+
el, specs) {
|
|
190
200
|
var _a;
|
|
191
201
|
const svgRenderedConditions = (_a = specs.def['#contentModels']['#SVGRenderable']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
192
202
|
if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
|
|
@@ -194,7 +204,9 @@ function isExposedElement(el, specs) {
|
|
|
194
204
|
}
|
|
195
205
|
return isNotMetaOrHiddenHTMLElement(el, specs);
|
|
196
206
|
}
|
|
197
|
-
function isNotMetaOrHiddenHTMLElement(
|
|
207
|
+
function isNotMetaOrHiddenHTMLElement(
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
209
|
+
el, specs) {
|
|
198
210
|
var _a;
|
|
199
211
|
const metadataConditions = (_a = specs.def['#contentModels']['#metadata']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
200
212
|
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,6 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function ariaSpecs(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
roles: import('../types').ARIARoleInSchema[];
|
|
7
|
-
graphicsRoles: import('../types').ARIARoleInSchema[];
|
|
8
|
-
props: import('../types').ARIAProperty[];
|
|
2
|
+
export declare function ariaSpecs(specs: MLMLSpec, version: ARIAVersion): {
|
|
3
|
+
readonly roles: readonly import("../types").ARIARoleInSchema[];
|
|
4
|
+
readonly graphicsRoles: readonly import("../types").ARIARoleInSchema[];
|
|
5
|
+
readonly props: readonly import("../types").ARIAProperty[];
|
|
9
6
|
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
2
|
import type { Category } from '../types/permitted-structures';
|
|
3
|
-
export declare function contentModelCategoryToTagNames(
|
|
4
|
-
contentModel: Category,
|
|
5
|
-
def: MLMLSpec['def'],
|
|
6
|
-
): ReadonlyArray<string>;
|
|
3
|
+
export declare function contentModelCategoryToTagNames(contentModel: Category, def: MLMLSpec['def']): ReadonlyArray<string>;
|
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
|
@@ -53,7 +53,10 @@ function getVersionResolvedARIA(specs, localName, namespace, version) {
|
|
|
53
53
|
}
|
|
54
54
|
aria = (0, resolve_version_1.resolveVersion)(spec, version);
|
|
55
55
|
if (aria.permittedRoles) {
|
|
56
|
-
aria
|
|
56
|
+
aria = {
|
|
57
|
+
...aria,
|
|
58
|
+
permittedRoles: optimizePermittedRoles(aria.permittedRoles),
|
|
59
|
+
};
|
|
57
60
|
}
|
|
58
61
|
cache.set(key, aria);
|
|
59
62
|
return aria;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { MLMLSpec, Attribute } from '../types';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getAttrSpecs(
|
|
4
|
-
localName: string,
|
|
5
|
-
namespace: NamespaceURI | null,
|
|
6
|
-
schema: MLMLSpec,
|
|
7
|
-
): Attribute[] | null;
|
|
3
|
+
export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): readonly Attribute[] | null;
|
|
8
4
|
type HasName = {
|
|
9
|
-
|
|
5
|
+
readonly name: string;
|
|
10
6
|
};
|
|
11
7
|
export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
|
|
12
8
|
export {};
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(
|
|
3
|
-
specs: Readonly<MLMLSpec>,
|
|
4
|
-
localName: string,
|
|
5
|
-
namespace: string | null,
|
|
6
|
-
version: ARIAVersion,
|
|
7
|
-
matches: Matches,
|
|
8
|
-
): import('..').ImplicitRole;
|
|
2
|
+
export declare function getImplicitRole(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): import("..").ImplicitRole;
|
|
@@ -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
|
}[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPermittedRoles = void 0;
|
|
4
|
+
const is_plain_object_1 = require("is-plain-object");
|
|
4
5
|
const merge_array_1 = require("../utils/merge-array");
|
|
5
6
|
const aria_specs_1 = require("./aria-specs");
|
|
6
7
|
const get_aria_1 = require("./get-aria");
|
|
@@ -26,17 +27,7 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
26
27
|
name: role.name,
|
|
27
28
|
})));
|
|
28
29
|
}
|
|
29
|
-
if (
|
|
30
|
-
permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
|
|
31
|
-
if (typeof role === 'string') {
|
|
32
|
-
return {
|
|
33
|
-
name: role,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return role;
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
else if (!(typeof permittedRoles === 'boolean')) {
|
|
30
|
+
if (isAAMInfo(permittedRoles)) {
|
|
40
31
|
if (permittedRoles['core-aam']) {
|
|
41
32
|
permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, roles
|
|
42
33
|
.filter(role => !role.isAbstract)
|
|
@@ -52,6 +43,16 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
52
43
|
})));
|
|
53
44
|
}
|
|
54
45
|
}
|
|
46
|
+
else if (typeof permittedRoles !== 'boolean') {
|
|
47
|
+
permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
|
|
48
|
+
if (typeof role === 'string') {
|
|
49
|
+
return {
|
|
50
|
+
name: role,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return role;
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
55
56
|
if (implicitRole) {
|
|
56
57
|
const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
|
|
57
58
|
return (0, merge_array_1.mergeArray)(implicitRoles.map(r => ({ name: r })), permittedRoleList);
|
|
@@ -59,3 +60,6 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
59
60
|
return permittedRoleList;
|
|
60
61
|
}
|
|
61
62
|
exports.getPermittedRoles = getPermittedRoles;
|
|
63
|
+
function isAAMInfo(permittedRoles) {
|
|
64
|
+
return (0, is_plain_object_1.isPlainObject)(permittedRoles);
|
|
65
|
+
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getRoleSpec(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
namespace: NamespaceURI,
|
|
7
|
-
version: ARIAVersion,
|
|
8
|
-
):
|
|
9
|
-
| (ARIARole & {
|
|
10
|
-
superClassRoles: ARIARoleInSchema[];
|
|
11
|
-
})
|
|
12
|
-
| null;
|
|
3
|
+
export declare function getRoleSpec(specs: MLMLSpec, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
|
|
4
|
+
superClassRoles: ARIARoleInSchema[];
|
|
5
|
+
}) | null;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
2
|
import type { Category } from '../types/permitted-structures';
|
|
3
|
-
export declare function getSelectorsByContentModelCategory(
|
|
4
|
-
specs: Readonly<MLMLSpec>,
|
|
5
|
-
category: Category,
|
|
6
|
-
): ReadonlyArray<string>;
|
|
3
|
+
export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(
|
|
3
|
-
specs: Readonly<Pick<ElementSpec, 'name' | K>[]>,
|
|
4
|
-
localName: string,
|
|
5
|
-
namespace: string | null,
|
|
6
|
-
): Pick<ElementSpec, 'name' | K> | null;
|
|
2
|
+
export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(specs: readonly Pick<ElementSpec, 'name' | K>[], localName: string, namespace: string | null): Pick<ElementSpec, "name" | K> | null;
|
|
@@ -6,7 +6,9 @@ const is_void_element_1 = require("./is-void-element");
|
|
|
6
6
|
* @see https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
|
|
7
7
|
* @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
|
8
8
|
*/
|
|
9
|
-
function isNothingContentModel(
|
|
9
|
+
function isNothingContentModel(
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
11
|
+
el) {
|
|
10
12
|
return (0, is_void_element_1.isVoidElement)(el) || ['iframe', 'template'].includes(el.localName);
|
|
11
13
|
}
|
|
12
14
|
exports.isNothingContentModel = isNothingContentModel;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function isPalpableElement(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
extendsSvg?: boolean;
|
|
7
|
-
extendsExposableElements?: boolean;
|
|
8
|
-
},
|
|
9
|
-
): boolean;
|
|
2
|
+
export declare function isPalpableElement(el: Element, specs: MLMLSpec, options?: {
|
|
3
|
+
readonly extendsSvg?: boolean;
|
|
4
|
+
readonly extendsExposableElements?: boolean;
|
|
5
|
+
}): boolean;
|