@markuplint/ml-spec 3.6.1 → 3.8.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/constant/aria-version.d.ts +2 -0
- package/lib/constant/aria-version.js +5 -0
- package/lib/dom-traverse/get-computed-role.d.ts +6 -1
- package/lib/dom-traverse/get-computed-role.js +31 -6
- package/lib/dom-traverse/get-non-presentational-ancestor.js +7 -1
- package/lib/dom-traverse/matches-context-role.d.ts +7 -0
- package/lib/dom-traverse/matches-context-role.js +27 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/specs/resolve-version.js +1 -1
- package/lib/specs/schema-to-spec.js +5 -0
- package/lib/types/aria.d.ts +20 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/validateAriaVersion.d.ts +2 -0
- package/lib/utils/validateAriaVersion.js +8 -0
- package/package.json +7 -7
- package/test/dom-traverse/accname-computation.spec.js +69 -0
- package/test/dom-traverse/get-computed-aria-props.spec.js +758 -0
- package/test/dom-traverse/get-computed-role.spec.js +294 -0
- package/test/dom-traverse/get-implicit-role.spec.js +40 -0
- package/test/dom-traverse/has-required-owned-elements.spec.js +34 -0
- package/test/dom-traverse/is-exposed.spec.js +70 -0
- package/test/dom-traverse/matches-context-role.spec.js +60 -0
- package/test/specs/get-attr-specs.spec.js +41 -0
- package/test/specs/get-implicit-role.spec.js +79 -0
- package/test/specs/get-permitted-roles.spec.js +418 -0
- package/test/specs/get-role-spec.spec.js +67 -0
- package/test/specs/get-spec-by-tag-name.spec.js +68 -0
- package/test/specs/resolve-version.spec.js +34 -0
- package/test/specs/schema-to-spec.spec.js +61 -0
- package/test/utils/resolve-namespace.spec.js +37 -0
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getComputedRole(
|
|
2
|
+
export declare function getComputedRole(
|
|
3
|
+
specs: MLMLSpec,
|
|
4
|
+
el: Element,
|
|
5
|
+
version: ARIAVersion,
|
|
6
|
+
assumeSingleNode?: boolean,
|
|
7
|
+
): ComputedRole;
|
|
@@ -8,14 +8,26 @@ const get_explicit_role_1 = require("./get-explicit-role");
|
|
|
8
8
|
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
|
+
const matches_context_role_1 = require("./matches-context-role");
|
|
11
12
|
const may_be_focusable_1 = require("./may-be-focusable");
|
|
12
13
|
function getComputedRole(specs,
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
14
|
-
el, version) {
|
|
15
|
-
var _a, _b
|
|
15
|
+
el, version, assumeSingleNode = false) {
|
|
16
|
+
var _a, _b;
|
|
16
17
|
const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, el, version);
|
|
17
18
|
const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
|
|
18
|
-
const computedRole = explicitRole.role
|
|
19
|
+
const computedRole = explicitRole.role
|
|
20
|
+
? explicitRole
|
|
21
|
+
: {
|
|
22
|
+
...implicitRole,
|
|
23
|
+
errorType: explicitRole.errorType === 'NO_EXPLICIT' ? undefined : explicitRole.errorType,
|
|
24
|
+
};
|
|
25
|
+
if (assumeSingleNode) {
|
|
26
|
+
return {
|
|
27
|
+
...computedRole,
|
|
28
|
+
errorType: 'NO_OWNER',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
19
31
|
/**
|
|
20
32
|
* Presentational Roles Conflict Resolution
|
|
21
33
|
*
|
|
@@ -42,6 +54,19 @@ el, version) {
|
|
|
42
54
|
* according to the sample code in WAI-ARIA specification.
|
|
43
55
|
*/
|
|
44
56
|
if (computedRole.role && computedRole.role.requiredContextRole.length > 0) {
|
|
57
|
+
/**
|
|
58
|
+
* An element fragment that serves as the root without a parent element
|
|
59
|
+
* cannot satisfy the "Required Context Role" condition.
|
|
60
|
+
* Therefore, under normal circumstances, the `role` will disappear.
|
|
61
|
+
* However, in this specific case, it will fall back to both explicit
|
|
62
|
+
* and implicit roles. Note that the explicit role takes precedence.
|
|
63
|
+
*/
|
|
64
|
+
if (el.parentElement === null) {
|
|
65
|
+
return {
|
|
66
|
+
...computedRole,
|
|
67
|
+
errorType: 'NO_OWNER',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
45
70
|
const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
|
|
46
71
|
if (!nonPresentationalAncestor.role) {
|
|
47
72
|
return {
|
|
@@ -50,7 +75,7 @@ el, version) {
|
|
|
50
75
|
errorType: 'NO_OWNER',
|
|
51
76
|
};
|
|
52
77
|
}
|
|
53
|
-
if (!((
|
|
78
|
+
if (!(0, matches_context_role_1.matchesContextRole)(computedRole.role.requiredContextRole, el, specs, version)) {
|
|
54
79
|
return {
|
|
55
80
|
el,
|
|
56
81
|
role: null,
|
|
@@ -113,7 +138,7 @@ el, version) {
|
|
|
113
138
|
*/
|
|
114
139
|
if (explicitRole.role) {
|
|
115
140
|
const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
|
|
116
|
-
if (nonPresentationalAncestor.role && ((
|
|
141
|
+
if (nonPresentationalAncestor.role && ((_a = nonPresentationalAncestor.role) === null || _a === void 0 ? void 0 : _a.requiredOwnedElements.length) > 0) {
|
|
117
142
|
if (nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
|
|
118
143
|
// const ancestor = nonPresentationalAncestor.el;
|
|
119
144
|
// const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
|
|
@@ -139,7 +164,7 @@ el, version) {
|
|
|
139
164
|
*/
|
|
140
165
|
const { props } = (0, aria_specs_1.ariaSpecs)(specs, version);
|
|
141
166
|
for (const attr of Array.from(el.attributes)) {
|
|
142
|
-
if ((
|
|
167
|
+
if ((_b = props.find(p => p.name === attr.name)) === null || _b === void 0 ? void 0 : _b.isGlobal) {
|
|
143
168
|
return {
|
|
144
169
|
...implicitRole,
|
|
145
170
|
errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
|
|
@@ -8,8 +8,14 @@ function getNonPresentationalAncestor(
|
|
|
8
8
|
el, specs, version) {
|
|
9
9
|
var _a;
|
|
10
10
|
let ancestor = el.parentElement;
|
|
11
|
+
/**
|
|
12
|
+
* In ARIA 1.1 and 1.2, the role of an element is not affected by the role of its ancestor elements.
|
|
13
|
+
*
|
|
14
|
+
* It is due to implementation considerations in Markuplint.
|
|
15
|
+
*/
|
|
16
|
+
const assumeSingleNode = version !== '1.1' && version !== '1.2';
|
|
11
17
|
while (ancestor) {
|
|
12
|
-
const ancestorRole = (0, get_computed_role_1.getComputedRole)(specs, ancestor, version);
|
|
18
|
+
const ancestorRole = (0, get_computed_role_1.getComputedRole)(specs, ancestor, version, assumeSingleNode);
|
|
13
19
|
if (!(0, is_presentational_1.isPresentational)((_a = ancestorRole.role) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
14
20
|
return ancestorRole;
|
|
15
21
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchesContextRole = void 0;
|
|
4
|
+
const get_computed_role_1 = require("./get-computed-role");
|
|
5
|
+
function matchesContextRole(conditions,
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
ownedEl, specs, version) {
|
|
8
|
+
return conditions.some(condition => matchesCondition(condition, ownedEl.parentElement, specs, version));
|
|
9
|
+
}
|
|
10
|
+
exports.matchesContextRole = matchesContextRole;
|
|
11
|
+
function matchesCondition(condition,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
13
|
+
parentEl, specs, version) {
|
|
14
|
+
const conditions = condition.split(/\s+>\s+/g).reverse();
|
|
15
|
+
while (conditions.length > 0) {
|
|
16
|
+
if (!parentEl) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const condition = conditions.shift();
|
|
20
|
+
const parentRole = (0, get_computed_role_1.getComputedRole)(specs, parentEl, version, true).role;
|
|
21
|
+
if (condition !== (parentRole === null || parentRole === void 0 ? void 0 : parentRole.name)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
parentEl = parentEl.parentElement;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './constant/aria-version';
|
|
1
2
|
export * from './dom-traverse/accname-computation';
|
|
2
3
|
export * from './dom-traverse/get-attr-specs';
|
|
3
4
|
export * from './dom-traverse/get-computed-aria-props';
|
|
@@ -23,3 +24,4 @@ export * from './types/aria';
|
|
|
23
24
|
export * from './types/attributes';
|
|
24
25
|
export * from './types/permitted-structures';
|
|
25
26
|
export * from './utils/resolve-namespace';
|
|
27
|
+
export * from './utils/validateAriaVersion';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./constant/aria-version"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./dom-traverse/accname-computation"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./dom-traverse/get-attr-specs"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./dom-traverse/get-computed-aria-props"), exports);
|
|
@@ -26,3 +27,4 @@ tslib_1.__exportStar(require("./types/aria"), exports);
|
|
|
26
27
|
tslib_1.__exportStar(require("./types/attributes"), exports);
|
|
27
28
|
tslib_1.__exportStar(require("./types/permitted-structures"), exports);
|
|
28
29
|
tslib_1.__exportStar(require("./utils/resolve-namespace"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./utils/validateAriaVersion"), exports);
|
|
@@ -7,7 +7,7 @@ function resolveVersion(aria, version) {
|
|
|
7
7
|
const permittedRoles = (_d = (_c = aria[version]) === null || _c === void 0 ? void 0 : _c.permittedRoles) !== null && _d !== void 0 ? _d : aria.permittedRoles;
|
|
8
8
|
const implicitProperties = (_f = (_e = aria[version]) === null || _e === void 0 ? void 0 : _e.implicitProperties) !== null && _f !== void 0 ? _f : aria.implicitProperties;
|
|
9
9
|
const properties = (_h = (_g = aria[version]) === null || _g === void 0 ? void 0 : _g.properties) !== null && _h !== void 0 ? _h : aria.properties;
|
|
10
|
-
const namingProhibited = version === '1.
|
|
10
|
+
const namingProhibited = version === '1.1' ? aria.namingProhibited : (_k = (_j = aria[version]) === null || _j === void 0 ? void 0 : _j.namingProhibited) !== null && _k !== void 0 ? _k : aria.namingProhibited;
|
|
11
11
|
const conditions = (_m = (_l = aria[version]) === null || _l === void 0 ? void 0 : _l.conditions) !== null && _m !== void 0 ? _m : aria.conditions;
|
|
12
12
|
return {
|
|
13
13
|
implicitRole,
|
|
@@ -39,6 +39,11 @@ function schemaToSpec(schemas) {
|
|
|
39
39
|
props: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
|
|
40
40
|
graphicsRoles: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].graphicsRoles, extendedSpec.def['#aria']['1.2'].graphicsRoles),
|
|
41
41
|
},
|
|
42
|
+
'1.3': {
|
|
43
|
+
roles: (0, merge_array_1.mergeArray)(def['#aria']['1.3'].roles, extendedSpec.def['#aria']['1.3'].roles),
|
|
44
|
+
props: (0, merge_array_1.mergeArray)(def['#aria']['1.3'].props, extendedSpec.def['#aria']['1.3'].props),
|
|
45
|
+
graphicsRoles: (0, merge_array_1.mergeArray)(def['#aria']['1.3'].graphicsRoles, extendedSpec.def['#aria']['1.3'].graphicsRoles),
|
|
46
|
+
},
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
49
|
if (extendedSpec.def['#contentModels']) {
|
package/lib/types/aria.d.ts
CHANGED
|
@@ -99,6 +99,26 @@ export interface ARIA {
|
|
|
99
99
|
properties?: PermittedARIAProperties;
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
+
'1.3'?: {
|
|
103
|
+
implicitRole?: ImplicitRole;
|
|
104
|
+
permittedRoles?: PermittedRoles;
|
|
105
|
+
namingProhibited?: true;
|
|
106
|
+
implicitProperties?: ImplicitProperties;
|
|
107
|
+
properties?: PermittedARIAProperties;
|
|
108
|
+
conditions?: {
|
|
109
|
+
/**
|
|
110
|
+
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
111
|
+
* via the `patternProperty` ".+".
|
|
112
|
+
*/
|
|
113
|
+
[k: string]: {
|
|
114
|
+
implicitRole?: ImplicitRole;
|
|
115
|
+
permittedRoles?: PermittedRoles;
|
|
116
|
+
namingProhibited?: true;
|
|
117
|
+
implicitProperties?: ImplicitProperties;
|
|
118
|
+
properties?: PermittedARIAProperties;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
102
122
|
'1.2'?: {
|
|
103
123
|
implicitRole?: ImplicitRole;
|
|
104
124
|
permittedRoles?: PermittedRoles;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ARIA } from './aria';
|
|
2
2
|
import type { AttributeJSON, AttributeType, GlobalAttributes } from './attributes';
|
|
3
3
|
import type { ContentModel, Category } from './permitted-structures';
|
|
4
|
+
import type { ariaVersions } from '../constant/aria-version';
|
|
4
5
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
5
6
|
import type { ReadonlyDeep } from 'type-fest';
|
|
6
7
|
/**
|
|
@@ -29,6 +30,7 @@ export type SpecDefs = {
|
|
|
29
30
|
readonly [category: string]: Readonly<Record<string, Partial<Attribute>>>;
|
|
30
31
|
};
|
|
31
32
|
readonly '#aria': {
|
|
33
|
+
readonly '1.3': ARIASpec;
|
|
32
34
|
readonly '1.2': ARIASpec;
|
|
33
35
|
readonly '1.1': ARIASpec;
|
|
34
36
|
};
|
|
@@ -189,7 +191,7 @@ export type ARIAAttributeValue =
|
|
|
189
191
|
| 'token'
|
|
190
192
|
| 'token list'
|
|
191
193
|
| 'URI';
|
|
192
|
-
export type ARIAVersion =
|
|
194
|
+
export type ARIAVersion = (typeof ariaVersions)[number];
|
|
193
195
|
export type EquivalentHtmlAttr = {
|
|
194
196
|
readonly htmlAttrName: string;
|
|
195
197
|
readonly isNotStrictEquivalent?: true;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAriaVersion = void 0;
|
|
4
|
+
const aria_version_1 = require("../constant/aria-version");
|
|
5
|
+
function validateAriaVersion(version) {
|
|
6
|
+
return aria_version_1.ariaVersions.includes(version);
|
|
7
|
+
}
|
|
8
|
+
exports.validateAriaVersion = validateAriaVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-spec",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Types and schema that specs of the Markup languages for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@markuplint/ml-ast": "3.1.0",
|
|
29
|
+
"@markuplint/types": "3.6.0",
|
|
29
30
|
"dom-accessibility-api": "^0.5.14",
|
|
30
31
|
"is-plain-object": "^5.0.0",
|
|
31
|
-
"tslib": "^2.4.1"
|
|
32
|
+
"tslib": "^2.4.1",
|
|
33
|
+
"type-fest": "^3.8.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
|
-
"@markuplint/test-tools": "3.
|
|
35
|
-
"
|
|
36
|
-
"json-schema-to-typescript": "11.0.2",
|
|
37
|
-
"type-fest": "^3.6.1"
|
|
36
|
+
"@markuplint/test-tools": "3.3.0",
|
|
37
|
+
"json-schema-to-typescript": "11.0.2"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "adc6e432cccba7cfad0dc8bf9f92e5aaf1107359"
|
|
40
40
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const { createJSDOMElement: c } = require('@markuplint/test-tools');
|
|
2
|
+
|
|
3
|
+
const { getAccname } = require('../../lib/dom-traverse/accname-computation');
|
|
4
|
+
|
|
5
|
+
test('Get accessible name', () => {
|
|
6
|
+
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
7
|
+
expect(getAccname(c('<div>text</div>'))).toBe('');
|
|
8
|
+
expect(getAccname(c('<div aria-label="label">text</div>'))).toBe('label');
|
|
9
|
+
expect(getAccname(c('<span aria-label="label">text</span>'))).toBe('label');
|
|
10
|
+
expect(getAccname(c('<img alt="alternative-text" />'))).toBe('alternative-text');
|
|
11
|
+
expect(getAccname(c('<img title="title" />'))).toBe('title');
|
|
12
|
+
expect(getAccname(c('<div><label for="a">label</label><input id="a" /></div>').children[1])).toBe('label');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Invisible element', () => {
|
|
16
|
+
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
17
|
+
expect(getAccname(c('<button aria-disabled="true">label</button>'))).toBe('label');
|
|
18
|
+
expect(getAccname(c('<button aria-hidden="true">label</button>'))).toBe('');
|
|
19
|
+
expect(getAccname(c('<button hidden>label</button>'))).toBe('');
|
|
20
|
+
expect(getAccname(c('<button style="display: none">label</button>'))).toBe('');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @see https://www.w3.org/TR/accname-1.1/#ex-1-example-1-element1-id-el1-aria-labelledby-el3-element2-id-el2-aria-labelledby-el1-element3-id-el3-hello-element3
|
|
25
|
+
*/
|
|
26
|
+
test('accname-1.1 Example 1', () => {
|
|
27
|
+
const complex = c(`<div>
|
|
28
|
+
<input id="el1" aria-labelledby="el3" />
|
|
29
|
+
<input id="el2" aria-labelledby="el1" />
|
|
30
|
+
<h1 id="el3"> hello </h1>
|
|
31
|
+
</div>`);
|
|
32
|
+
expect(getAccname(complex.children[0])).toBe('hello');
|
|
33
|
+
expect(getAccname(complex.children[1])).toBe('');
|
|
34
|
+
expect(getAccname(complex.children[2])).toBe('hello');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @see https://www.w3.org/TR/accname-1.1/#ex-2-example-2-h1-files-h1-ul-li-a-id-file_row1-href-files-documentation-pdf-documentation-pdf-a-span-role-button-tabindex-0-id-del_row1-aria-label-delete-aria-labelledby-del_row1-file_row1-span-li-li-a-id-file_row2-href-files-holidayletter-pdf-holidayletter-pdf-a-span-role-button-tabindex-0-id-del_row2-aria-label-delete-aria-labelledby-del_row2-file_row2-span-li-ul
|
|
39
|
+
*/
|
|
40
|
+
test('accname-1.1 Example 2', () => {
|
|
41
|
+
const complex = c(`<ul>
|
|
42
|
+
<li>
|
|
43
|
+
<a id="file_row1" href="./files/Documentation.pdf">Documentation.pdf</a>
|
|
44
|
+
<span role="button" tabindex="0" id="del_row1" aria-label="Delete" aria-labelledby="del_row1 file_row1"></span>
|
|
45
|
+
</li>
|
|
46
|
+
<li>
|
|
47
|
+
<a id="file_row2" href="./files/HolidayLetter.pdf">HolidayLetter.pdf</a>
|
|
48
|
+
<span role="button" tabindex="0" id="del_row2" aria-label="Delete" aria-labelledby="del_row2 file_row2"></span>
|
|
49
|
+
</li>
|
|
50
|
+
</ul>`);
|
|
51
|
+
const spans = complex.querySelectorAll('span');
|
|
52
|
+
expect(getAccname(spans[0])).toBe('Delete Documentation.pdf');
|
|
53
|
+
expect(getAccname(spans[1])).toBe('Delete HolidayLetter.pdf');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @see https://www.w3.org/TR/accname-1.1/#ex-3-example-3-div-role-checkbox-aria-checked-false-flash-the-screen-span-role-textbox-aria-multiline-false-5-span-times-div
|
|
58
|
+
*/
|
|
59
|
+
test('accname-1.1 Example 3', () => {
|
|
60
|
+
const complex = c(
|
|
61
|
+
'<div role="checkbox" aria-checked="false">Flash the screen <span role="textbox" aria-multiline="false"> 5 </span> times</div>',
|
|
62
|
+
);
|
|
63
|
+
expect(getAccname(complex)).toBe('Flash the screen 5 times');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('with comment', () => {
|
|
67
|
+
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
68
|
+
expect(getAccname(c('<button>label<!-- comment --></button>'))).toBe('label');
|
|
69
|
+
});
|