@markuplint/ml-spec 2.1.0 → 3.0.0-alpha.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.d.ts +1 -0
- package/lib/dom-traverse/accname-computation.js +8 -0
- package/lib/dom-traverse/focusability-computation.d.ts +1 -0
- package/lib/dom-traverse/focusability-computation.js +8 -0
- package/lib/dom-traverse/get-aria.d.ts +9 -0
- package/lib/dom-traverse/get-aria.js +54 -0
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -0
- package/lib/dom-traverse/get-attr-specs.js +8 -0
- package/lib/dom-traverse/get-computed-role.d.ts +2 -0
- package/lib/dom-traverse/get-computed-role.js +170 -0
- package/lib/dom-traverse/get-explicit-role.d.ts +2 -0
- package/lib/dom-traverse/get-explicit-role.js +102 -0
- package/lib/dom-traverse/get-implicit-role.d.ts +3 -0
- package/lib/dom-traverse/get-implicit-role.js +37 -0
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +5 -0
- package/lib/dom-traverse/get-non-presentational-ancestor.js +21 -0
- package/lib/dom-traverse/get-permitted-roles.d.ts +5 -0
- package/lib/dom-traverse/get-permitted-roles.js +8 -0
- package/lib/dom-traverse/get-spec.d.ts +2 -0
- package/lib/dom-traverse/get-spec.js +8 -0
- package/lib/dom-traverse/has-required-owned-elements.d.ts +3 -0
- package/lib/dom-traverse/has-required-owned-elements.js +81 -0
- package/lib/dom-traverse/may-be-focusable.d.ts +2 -0
- package/lib/dom-traverse/may-be-focusable.js +22 -0
- package/lib/index.d.ts +17 -6
- package/lib/index.js +17 -6
- package/lib/specs/aria-spec.d.ts +5 -0
- package/lib/specs/aria-spec.js +12 -0
- package/lib/specs/aria-specs.d.ts +6 -0
- package/lib/specs/aria-specs.js +8 -0
- package/lib/specs/content-model-category-to-tag-names.d.ts +3 -0
- package/lib/specs/content-model-category-to-tag-names.js +15 -0
- package/lib/specs/get-aria.d.ts +3 -0
- package/lib/specs/get-aria.js +71 -0
- package/lib/specs/get-attr-specs.d.ts +8 -0
- package/lib/{get-attr-specs.js → specs/get-attr-specs.js} +8 -6
- package/lib/specs/get-implicit-role.d.ts +2 -0
- package/lib/specs/get-implicit-role.js +12 -0
- package/lib/specs/get-permitted-roles.d.ts +12 -0
- package/lib/specs/get-permitted-roles.js +61 -0
- package/lib/specs/get-role-spec.d.ts +5 -0
- package/lib/specs/get-role-spec.js +52 -0
- package/lib/specs/get-selectors-by-content-model-category.d.ts +3 -0
- package/lib/specs/get-selectors-by-content-model-category.js +8 -0
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -0
- package/lib/specs/get-spec-by-tag-name.js +16 -0
- package/lib/{get-spec.d.ts → specs/get-spec.d.ts} +4 -4
- package/lib/{get-spec.js → specs/get-spec.js} +1 -1
- package/lib/specs/html-spec.d.ts +6 -0
- package/lib/specs/html-spec.js +16 -0
- package/lib/specs/is-presentational.d.ts +1 -0
- package/lib/specs/is-presentational.js +10 -0
- package/lib/specs/resolve-namespace.d.ts +9 -0
- package/lib/specs/resolve-namespace.js +26 -0
- package/lib/specs/resolve-version.d.ts +3 -0
- package/lib/specs/resolve-version.js +21 -0
- package/lib/specs/schema-to-spec.d.ts +13 -0
- package/lib/specs/schema-to-spec.js +93 -0
- package/lib/types/aria.d.ts +130 -0
- package/lib/{attributes.js → types/aria.js} +0 -0
- package/lib/{attributes.d.ts → types/attributes.d.ts} +2 -10
- package/lib/{permitted-structres.js → types/attributes.js} +0 -0
- package/lib/{types.d.ts → types/index.d.ts} +49 -64
- package/lib/{types.js → types/index.js} +0 -0
- package/lib/{permitted-structres.d.ts → types/permitted-structres.d.ts} +14 -23
- package/lib/types/permitted-structres.js +8 -0
- package/lib/utils/cache.d.ts +10 -0
- package/lib/utils/cache.js +42 -0
- package/lib/utils/get-ns.d.ts +2 -0
- package/lib/{get-ns.js → utils/get-ns.js} +3 -0
- package/lib/utils/merge-array.d.ts +5 -0
- package/lib/utils/merge-array.js +36 -0
- package/lib/utils/resolve-namespace.d.ts +9 -0
- package/lib/utils/resolve-namespace.js +31 -0
- package/lib/utils.d.ts +6 -3
- package/lib/utils.js +15 -1
- package/package.json +10 -6
- package/schemas/aria.schema.json +258 -0
- package/schemas/attributes.schema.json +3 -22
- package/schemas/{permitted-structures.schema.json → content-models.schema.json} +52 -81
- package/schemas/element.schema.json +11 -0
- package/src/dom-traverse/accname-computation.spec.ts +69 -0
- package/src/dom-traverse/accname-computation.ts +5 -0
- package/src/dom-traverse/get-attr-specs.ts +8 -0
- package/src/dom-traverse/get-computed-role.spec.ts +134 -0
- package/src/dom-traverse/get-computed-role.ts +181 -0
- package/src/dom-traverse/get-explicit-role.ts +112 -0
- package/src/dom-traverse/get-implicit-role.ts +36 -0
- package/src/dom-traverse/get-non-presentational-ancestor.ts +20 -0
- package/src/dom-traverse/get-permitted-roles.ts +7 -0
- package/src/dom-traverse/get-spec.ts +7 -0
- package/src/dom-traverse/has-required-owned-elements.spec.ts +36 -0
- package/src/dom-traverse/has-required-owned-elements.ts +85 -0
- package/src/dom-traverse/may-be-focusable.ts +21 -0
- package/src/index.ts +17 -6
- package/src/specs/aria-specs.ts +6 -0
- package/src/specs/content-model-category-to-tag-names.ts +15 -0
- package/src/specs/get-aria.ts +85 -0
- package/src/{get-attr-specs.spec.ts → specs/get-attr-specs.spec.ts} +4 -7
- package/src/{get-attr-specs.ts → specs/get-attr-specs.ts} +12 -7
- package/src/specs/get-implicit-role.spec.ts +81 -0
- package/src/specs/get-implicit-role.ts +17 -0
- package/src/specs/get-permitted-roles.spec.ts +420 -0
- package/src/specs/get-permitted-roles.ts +87 -0
- package/src/specs/get-role-spec.spec.ts +67 -0
- package/src/specs/get-role-spec.ts +72 -0
- package/src/specs/get-selectors-by-content-model-category.ts +10 -0
- package/src/specs/get-spec-by-tag-name.spec.ts +68 -0
- package/src/specs/get-spec-by-tag-name.ts +16 -0
- package/src/specs/is-presentational.ts +6 -0
- package/src/specs/resolve-version.ts +20 -0
- package/src/{get-spec.spec.ts → specs/schema-to-spec.spec.ts} +2 -2
- package/src/{get-spec.ts → specs/schema-to-spec.ts} +22 -8
- package/src/types/aria.ts +147 -0
- package/src/{attributes.ts → types/attributes.ts} +2 -12
- package/src/{types.ts → types/index.ts} +69 -68
- package/src/{permitted-structres.ts → types/permitted-structres.ts} +15 -25
- package/src/{get-ns.ts → utils/get-ns.ts} +6 -1
- package/src/{utils.ts → utils/merge-array.ts} +0 -0
- package/src/utils/resolve-namespace.spec.ts +37 -0
- package/src/utils/resolve-namespace.ts +40 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/get-attr-specs.d.ts +0 -7
- package/lib/get-ns.d.ts +0 -1
- package/lib/get-spec-by-tag-name.d.ts +0 -2
- package/lib/get-spec-by-tag-name.js +0 -31
- package/schemas/wai-aria.schema.json +0 -87
- package/src/get-spec-by-tag-name.ts +0 -32
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MLMLSpec } from '../types';
|
|
2
|
+
import type { Category } from '../types/permitted-structres';
|
|
3
|
+
|
|
4
|
+
const cache = new Map<Category, ReadonlyArray<string>>();
|
|
5
|
+
|
|
6
|
+
export function contentModelCategoryToTagNames(contentModel: Category, specs: MLMLSpec): ReadonlyArray<string> {
|
|
7
|
+
const cached = cache.get(contentModel);
|
|
8
|
+
if (cached) {
|
|
9
|
+
return cached;
|
|
10
|
+
}
|
|
11
|
+
const tags: string[] | undefined = specs.def['#contentModels'][contentModel];
|
|
12
|
+
const sortedTag = Object.freeze(tags && Array.isArray(tags) ? tags.sort() : []);
|
|
13
|
+
cache.set(contentModel, sortedTag);
|
|
14
|
+
return sortedTag;
|
|
15
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
|
+
import type { ARIA, PermittedRoles } from '../types/aria';
|
|
3
|
+
|
|
4
|
+
import { getSpecByTagName } from './get-spec-by-tag-name';
|
|
5
|
+
import { resolveVersion } from './resolve-version';
|
|
6
|
+
|
|
7
|
+
const cache = new Map<string, Omit<ARIA, ARIAVersion> | null>();
|
|
8
|
+
|
|
9
|
+
export function getARIA(
|
|
10
|
+
specs: Readonly<MLMLSpec>,
|
|
11
|
+
localName: string,
|
|
12
|
+
namespace: string | null,
|
|
13
|
+
version: ARIAVersion,
|
|
14
|
+
matches: Matches,
|
|
15
|
+
): Omit<ARIA, ARIAVersion | 'conditions'> | null {
|
|
16
|
+
const aria = getVersionResolvedARIA(specs, localName, namespace, version);
|
|
17
|
+
if (!aria) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const conditions = aria.conditions;
|
|
21
|
+
if (!conditions) {
|
|
22
|
+
return aria;
|
|
23
|
+
}
|
|
24
|
+
const conds = Object.keys(conditions);
|
|
25
|
+
let { implicitRole, permittedRoles, implicitProperties, properties, namingProhibited } = aria;
|
|
26
|
+
for (const cond of conds) {
|
|
27
|
+
if (!matches(cond)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const condARIA = conditions[cond];
|
|
31
|
+
implicitRole = condARIA.implicitRole ?? implicitRole;
|
|
32
|
+
permittedRoles = condARIA.permittedRoles ?? permittedRoles;
|
|
33
|
+
implicitProperties = condARIA.implicitProperties ?? implicitProperties;
|
|
34
|
+
properties = condARIA.properties ?? properties;
|
|
35
|
+
namingProhibited = condARIA.namingProhibited ?? namingProhibited;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
implicitRole,
|
|
39
|
+
permittedRoles,
|
|
40
|
+
implicitProperties,
|
|
41
|
+
properties,
|
|
42
|
+
namingProhibited,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getVersionResolvedARIA(
|
|
47
|
+
specs: Readonly<MLMLSpec>,
|
|
48
|
+
localName: string,
|
|
49
|
+
namespace: string | null,
|
|
50
|
+
version: ARIAVersion,
|
|
51
|
+
) {
|
|
52
|
+
const key = localName + namespace + version;
|
|
53
|
+
let aria = cache.get(key);
|
|
54
|
+
if (aria !== undefined) {
|
|
55
|
+
return aria;
|
|
56
|
+
}
|
|
57
|
+
const spec = getSpecByTagName(specs, localName, namespace)?.aria;
|
|
58
|
+
if (!spec) {
|
|
59
|
+
cache.set(key, null);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
aria = resolveVersion(spec, version);
|
|
63
|
+
if (aria.permittedRoles) {
|
|
64
|
+
aria.permittedRoles = optimizePermittedRoles(aria.permittedRoles);
|
|
65
|
+
}
|
|
66
|
+
cache.set(key, aria);
|
|
67
|
+
return aria;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function optimizePermittedRoles(permittedRoles: PermittedRoles) {
|
|
71
|
+
if (!Array.isArray(permittedRoles)) {
|
|
72
|
+
return permittedRoles;
|
|
73
|
+
}
|
|
74
|
+
const unique = new Set(permittedRoles);
|
|
75
|
+
|
|
76
|
+
// https://www.w3.org/TR/wai-aria-1.2/#note-regarding-the-aria-1-1-none-role
|
|
77
|
+
if (unique.has('presentation')) {
|
|
78
|
+
unique.add('none');
|
|
79
|
+
}
|
|
80
|
+
if (unique.has('none')) {
|
|
81
|
+
unique.add('presentation');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return Array.from(unique).sort();
|
|
85
|
+
}
|
|
@@ -4,10 +4,9 @@ import { getAttrSpecs } from './get-attr-specs';
|
|
|
4
4
|
|
|
5
5
|
describe('getSpec', () => {
|
|
6
6
|
test('svg:image[x]', () => {
|
|
7
|
-
const specs = getAttrSpecs('
|
|
7
|
+
const specs = getAttrSpecs('image', 'http://www.w3.org/2000/svg', htmlSpec);
|
|
8
8
|
const x = specs?.find(spec => spec.name === 'x');
|
|
9
9
|
expect(x).toStrictEqual({
|
|
10
|
-
ref: 'https://svgwg.org/svg2-draft/geometry.html#XProperty',
|
|
11
10
|
defaultValue: '0',
|
|
12
11
|
name: 'x',
|
|
13
12
|
type: ['<svg-length>', '<percentage>'],
|
|
@@ -16,10 +15,9 @@ describe('getSpec', () => {
|
|
|
16
15
|
});
|
|
17
16
|
|
|
18
17
|
test('svg:foreignObject[x]', () => {
|
|
19
|
-
const specs = getAttrSpecs('
|
|
18
|
+
const specs = getAttrSpecs('foreignObject', 'http://www.w3.org/2000/svg', htmlSpec);
|
|
20
19
|
const x = specs?.find(spec => spec.name === 'x');
|
|
21
20
|
expect(x).toStrictEqual({
|
|
22
|
-
ref: 'https://svgwg.org/svg2-draft/geometry.html#XProperty',
|
|
23
21
|
defaultValue: '0',
|
|
24
22
|
description:
|
|
25
23
|
'The x coordinate of the foreignObject. Value type: <length>|<percentage> ; Default value: 0; Animatable: yes',
|
|
@@ -30,10 +28,9 @@ describe('getSpec', () => {
|
|
|
30
28
|
});
|
|
31
29
|
|
|
32
30
|
test('svg:linearGradient[xlink:href]', () => {
|
|
33
|
-
const specs = getAttrSpecs('
|
|
31
|
+
const specs = getAttrSpecs('linearGradient', 'http://www.w3.org/2000/svg', htmlSpec);
|
|
34
32
|
const x = specs?.find(spec => spec.name === 'xlink:href');
|
|
35
33
|
expect(x).toStrictEqual({
|
|
36
|
-
ref: 'https://www.w3.org/TR/xlink11/#link-locators',
|
|
37
34
|
description:
|
|
38
35
|
'Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.An <IRI> reference to another <linearGradient> element that will be used as a template. Value type: <IRI> ; Default value: none; Animatable: yes',
|
|
39
36
|
name: 'xlink:href',
|
|
@@ -43,7 +40,7 @@ describe('getSpec', () => {
|
|
|
43
40
|
});
|
|
44
41
|
|
|
45
42
|
test('img[fetchpriority] (experimental spec)', () => {
|
|
46
|
-
const attrs = getAttrSpecs('img', htmlSpec);
|
|
43
|
+
const attrs = getAttrSpecs('img', null, htmlSpec);
|
|
47
44
|
const fetchpriority = attrs?.find(attr => attr.name === 'fetchpriority');
|
|
48
45
|
expect(fetchpriority?.experimental).toBe(true);
|
|
49
46
|
});
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import type { MLMLSpec, Attribute } from '
|
|
1
|
+
import type { MLMLSpec, Attribute } from '../types';
|
|
2
|
+
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
+
|
|
4
|
+
import { resolveNamespace } from '../utils/resolve-namespace';
|
|
2
5
|
|
|
3
6
|
const cacheMap = new Map<string, Attribute[] | null>();
|
|
4
7
|
const schemaCache = new WeakSet<MLMLSpec>();
|
|
5
8
|
|
|
6
|
-
export function getAttrSpecs(
|
|
9
|
+
export function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec) {
|
|
7
10
|
if (!schemaCache.has(schema)) {
|
|
8
11
|
cacheMap.clear();
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
const
|
|
14
|
+
const { localNameWithNS } = resolveNamespace(localName, namespace || undefined);
|
|
15
|
+
|
|
16
|
+
const cache = cacheMap.get(localNameWithNS);
|
|
12
17
|
|
|
13
18
|
if (cache !== undefined) {
|
|
14
19
|
return cache;
|
|
@@ -16,9 +21,9 @@ export function getAttrSpecs(nameWithNS: string, schema: MLMLSpec) {
|
|
|
16
21
|
|
|
17
22
|
schemaCache.add(schema);
|
|
18
23
|
|
|
19
|
-
const elSpec = schema.specs.find(spec => spec.name ===
|
|
24
|
+
const elSpec = schema.specs.find(spec => spec.name === localNameWithNS);
|
|
20
25
|
if (!elSpec) {
|
|
21
|
-
cacheMap.set(
|
|
26
|
+
cacheMap.set(localNameWithNS, null);
|
|
22
27
|
return null;
|
|
23
28
|
}
|
|
24
29
|
|
|
@@ -78,7 +83,7 @@ export function getAttrSpecs(nameWithNS: string, schema: MLMLSpec) {
|
|
|
78
83
|
for (const attr of attrList) {
|
|
79
84
|
if (!attr.type) {
|
|
80
85
|
throw new Error(
|
|
81
|
-
`The type is empty in the ${attr.name} attribute of the ${
|
|
86
|
+
`The type is empty in the ${attr.name} attribute of the ${localName} element,
|
|
82
87
|
'packages',
|
|
83
88
|
'@markuplint',
|
|
84
89
|
'html-spec',
|
|
@@ -92,7 +97,7 @@ export function getAttrSpecs(nameWithNS: string, schema: MLMLSpec) {
|
|
|
92
97
|
|
|
93
98
|
attrList.sort(nameCompare);
|
|
94
99
|
|
|
95
|
-
cacheMap.set(
|
|
100
|
+
cacheMap.set(localNameWithNS, attrList);
|
|
96
101
|
return attrList;
|
|
97
102
|
}
|
|
98
103
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ARIAVersion } from '../types';
|
|
2
|
+
|
|
3
|
+
import specs from '@markuplint/html-spec';
|
|
4
|
+
import { createSelector } from '@markuplint/selector';
|
|
5
|
+
import { createJSDOMElement } from '@markuplint/test-tools';
|
|
6
|
+
|
|
7
|
+
import { getImplicitRole } from './get-implicit-role';
|
|
8
|
+
|
|
9
|
+
function c(html: string, version: ARIAVersion) {
|
|
10
|
+
const el = createJSDOMElement(html);
|
|
11
|
+
return getImplicitRole(
|
|
12
|
+
specs,
|
|
13
|
+
el.localName,
|
|
14
|
+
el.namespaceURI,
|
|
15
|
+
version,
|
|
16
|
+
selector => !!createSelector(selector, specs).match(el),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('getImplicitRole', () => {
|
|
21
|
+
test('the a element', () => {
|
|
22
|
+
expect(c('<a></a>', '1.2')).toBe(false);
|
|
23
|
+
expect(c('<a name="foo"></a>', '1.2')).toBe(false);
|
|
24
|
+
expect(c('<a href></a>', '1.2')).toBe('link');
|
|
25
|
+
expect(c('<a href=""></a>', '1.2')).toBe('link');
|
|
26
|
+
expect(c('<a href="path/to"></a>', '1.2')).toBe('link');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('the area element', () => {
|
|
30
|
+
expect(c('<area />', '1.2')).toBe(false);
|
|
31
|
+
expect(c('<area shape="rect" />', '1.2')).toBe(false);
|
|
32
|
+
expect(c('<area href />', '1.2')).toBe('link');
|
|
33
|
+
expect(c('<area href="" />', '1.2')).toBe('link');
|
|
34
|
+
expect(c('<area href="path/to" />', '1.2')).toBe('link');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('the article element', () => {
|
|
38
|
+
expect(c('<article></article>', '1.2')).toBe('article');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('the aside element', () => {
|
|
42
|
+
expect(c('<aside></aside>', '1.2')).toBe('complementary');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('the audio element', () => {
|
|
46
|
+
expect(c('<audio></audio>', '1.2')).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('the h1 element', () => {
|
|
50
|
+
expect(c('<h1></h1>', '1.2')).toBe('heading');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('the header element', () => {
|
|
54
|
+
expect(c('<header></header>', '1.2')).toBe('banner');
|
|
55
|
+
expect(c('<header><article></article></header>', '1.2')).toBe('generic');
|
|
56
|
+
expect(c('<header><article></article></header>', '1.1')).toBe(false);
|
|
57
|
+
expect(c('<header><div></div></header>', '1.2')).toBe('banner');
|
|
58
|
+
expect(c('<header><div role="article"></div></header>', '1.2')).toBe('generic');
|
|
59
|
+
expect(c('<header><div role="article"></div></header>', '1.1')).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('the img element', () => {
|
|
63
|
+
expect(c('<img />', '1.2')).toBe('img');
|
|
64
|
+
expect(c('<img alt />', '1.2')).toBe('presentation');
|
|
65
|
+
expect(c('<img alt="" />', '1.2')).toBe('presentation');
|
|
66
|
+
expect(c('<img alt="foo" />', '1.2')).toBe('img');
|
|
67
|
+
expect(c('<img aria-label="foo" />', '1.2')).toBe('img');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('the form element', () => {
|
|
71
|
+
expect(c('<form></form>', '1.2')).toBe('form');
|
|
72
|
+
expect(c('<form></form>', '1.1')).toBe(false);
|
|
73
|
+
expect(c('<form aria-label="foo"></form>', '1.2')).toBe('form');
|
|
74
|
+
expect(c('<form aria-label="foo"></form>', '1.1')).toBe('form');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('the section element', () => {
|
|
78
|
+
expect(c('<section></section>', '1.2')).toBe(false);
|
|
79
|
+
expect(c('<section aria-label="foo"></section>', '1.2')).toBe('region');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
|
+
|
|
3
|
+
import { getARIA } from './get-aria';
|
|
4
|
+
|
|
5
|
+
export function getImplicitRole(
|
|
6
|
+
specs: Readonly<MLMLSpec>,
|
|
7
|
+
localName: string,
|
|
8
|
+
namespace: string | null,
|
|
9
|
+
version: ARIAVersion,
|
|
10
|
+
matches: Matches,
|
|
11
|
+
) {
|
|
12
|
+
const aria = getARIA(specs, localName, namespace, version, matches);
|
|
13
|
+
if (!aria) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return aria.implicitRole;
|
|
17
|
+
}
|