@markuplint/ml-spec 3.0.0-dev.24 → 3.0.0-dev.290
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 +2 -0
- package/lib/dom-traverse/accname-computation.js +6 -7
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
- package/lib/dom-traverse/get-attr-specs.js +5 -7
- package/lib/dom-traverse/get-computed-aria-props.d.ts +2 -2
- package/lib/dom-traverse/get-computed-aria-props.js +10 -13
- package/lib/dom-traverse/get-computed-role.d.ts +2 -2
- package/lib/dom-traverse/get-computed-role.js +104 -31
- package/lib/dom-traverse/get-content-model.d.ts +4 -3
- package/lib/dom-traverse/get-content-model.js +8 -11
- package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
- package/lib/dom-traverse/get-explicit-role.js +14 -14
- package/lib/dom-traverse/get-implicit-role.d.ts +3 -3
- package/lib/dom-traverse/get-implicit-role.js +12 -13
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.js +13 -10
- package/lib/dom-traverse/get-permitted-roles.d.ts +4 -4
- package/lib/dom-traverse/get-permitted-roles.js +5 -7
- package/lib/dom-traverse/get-spec.d.ts +2 -2
- package/lib/dom-traverse/get-spec.js +5 -7
- package/lib/dom-traverse/has-required-owned-elements.d.ts +3 -3
- package/lib/dom-traverse/has-required-owned-elements.js +21 -22
- package/lib/dom-traverse/is-exposed.d.ts +2 -2
- package/lib/dom-traverse/is-exposed.js +47 -18
- package/lib/dom-traverse/matches-context-role.d.ts +2 -0
- package/lib/dom-traverse/matches-context-role.js +23 -0
- package/lib/dom-traverse/may-be-focusable.d.ts +2 -2
- package/lib/dom-traverse/may-be-focusable.js +5 -7
- package/lib/index.d.ts +28 -24
- package/lib/index.js +28 -27
- package/lib/specs/aria-specs.d.ts +5 -5
- package/lib/specs/aria-specs.js +1 -5
- package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
- package/lib/specs/content-model-category-to-tag-names.js +1 -5
- package/lib/specs/get-aria.d.ts +4 -3
- package/lib/specs/get-aria.js +18 -18
- package/lib/specs/get-attr-specs.d.ts +3 -3
- package/lib/specs/get-attr-specs.js +5 -22
- package/lib/specs/get-implicit-role.d.ts +2 -2
- package/lib/specs/get-implicit-role.js +3 -7
- package/lib/specs/get-permitted-roles.d.ts +4 -4
- package/lib/specs/get-permitted-roles.js +29 -28
- package/lib/specs/get-role-spec.d.ts +2 -2
- package/lib/specs/get-role-spec.js +10 -14
- package/lib/specs/get-selectors-by-content-model-category.d.ts +3 -3
- package/lib/specs/get-selectors-by-content-model-category.js +2 -6
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -2
- package/lib/specs/get-spec-by-tag-name.js +4 -8
- package/lib/specs/is-nothing-content-model.js +5 -7
- package/lib/specs/is-palpable-elements.d.ts +4 -4
- package/lib/specs/is-palpable-elements.js +7 -10
- package/lib/specs/is-presentational.js +1 -5
- package/lib/specs/is-void-element.js +3 -5
- package/lib/specs/resolve-version.d.ts +4 -3
- package/lib/specs/resolve-version.js +7 -12
- package/lib/specs/schema-to-spec.d.ts +4 -4
- package/lib/specs/schema-to-spec.js +30 -24
- package/lib/types/aria.d.ts +25 -4
- package/lib/types/aria.js +1 -3
- package/lib/types/attributes.d.ts +3 -4
- package/lib/types/attributes.js +1 -3
- package/lib/types/index.d.ts +93 -92
- package/lib/types/index.js +1 -2
- package/lib/types/permitted-structures.d.ts +6 -2
- package/lib/types/permitted-structures.js +1 -3
- package/lib/utils/get-ns.js +1 -5
- package/lib/utils/merge-array.d.ts +2 -2
- package/lib/utils/merge-array.js +1 -5
- package/lib/utils/resolve-namespace.js +4 -8
- package/lib/utils/validateAriaVersion.d.ts +2 -0
- package/lib/utils/validateAriaVersion.js +4 -0
- package/package.json +20 -10
- package/lib/types/permitted-structres.d.ts +0 -58
- package/lib/types/permitted-structres.js +0 -8
- package/schemas/aria.schema.json +0 -258
- package/schemas/attributes.schema.json +0 -204
- package/schemas/content-models.schema.json +0 -199
- package/schemas/element.schema.json +0 -11
- package/schemas/global-attributes.schema.json +0 -761
- package/src/dom-traverse/accname-computation.spec.ts +0 -69
- package/src/dom-traverse/accname-computation.ts +0 -5
- package/src/dom-traverse/get-attr-specs.ts +0 -8
- package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
- package/src/dom-traverse/get-computed-aria-props.ts +0 -130
- package/src/dom-traverse/get-computed-role.spec.ts +0 -134
- package/src/dom-traverse/get-computed-role.ts +0 -181
- package/src/dom-traverse/get-content-model.ts +0 -32
- package/src/dom-traverse/get-explicit-role.ts +0 -112
- package/src/dom-traverse/get-implicit-role.ts +0 -36
- package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
- package/src/dom-traverse/get-permitted-roles.ts +0 -7
- package/src/dom-traverse/get-spec.ts +0 -7
- package/src/dom-traverse/has-required-owned-elements.spec.ts +0 -36
- package/src/dom-traverse/has-required-owned-elements.ts +0 -85
- package/src/dom-traverse/is-exposed.spec.ts +0 -50
- package/src/dom-traverse/is-exposed.ts +0 -196
- package/src/dom-traverse/may-be-focusable.ts +0 -21
- package/src/index.ts +0 -24
- package/src/specs/aria-specs.ts +0 -6
- package/src/specs/content-model-category-to-tag-names.ts +0 -15
- package/src/specs/get-aria.ts +0 -85
- package/src/specs/get-attr-specs.spec.ts +0 -47
- package/src/specs/get-attr-specs.ts +0 -116
- package/src/specs/get-implicit-role.spec.ts +0 -81
- package/src/specs/get-implicit-role.ts +0 -17
- package/src/specs/get-permitted-roles.spec.ts +0 -420
- package/src/specs/get-permitted-roles.ts +0 -87
- package/src/specs/get-role-spec.spec.ts +0 -67
- package/src/specs/get-role-spec.ts +0 -72
- package/src/specs/get-selectors-by-content-model-category.ts +0 -10
- package/src/specs/get-spec-by-tag-name.spec.ts +0 -68
- package/src/specs/get-spec-by-tag-name.ts +0 -20
- package/src/specs/is-nothing-content-model.ts +0 -9
- package/src/specs/is-palpable-elements.ts +0 -55
- package/src/specs/is-presentational.ts +0 -6
- package/src/specs/is-void-element.ts +0 -22
- package/src/specs/resolve-version.ts +0 -20
- package/src/specs/schema-to-spec.spec.ts +0 -39
- package/src/specs/schema-to-spec.ts +0 -103
- package/src/types/aria.ts +0 -153
- package/src/types/attributes.ts +0 -1524
- package/src/types/index.ts +0 -255
- package/src/types/permitted-structres.ts +0 -100
- package/src/types/permitted-structures.ts +0 -96
- package/src/utils/get-ns.ts +0 -18
- package/src/utils/merge-array.ts +0 -35
- package/src/utils/resolve-namespace.spec.ts +0 -37
- package/src/utils/resolve-namespace.ts +0 -40
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { computeAccessibleName } from 'dom-accessibility-api';
|
|
3
|
+
export function getAccname(
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
5
|
+
el) {
|
|
6
|
+
return computeAccessibleName(el);
|
|
7
7
|
}
|
|
8
|
-
exports.getAccname = getAccname;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): import("../types").Attribute[] | null;
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import("../types/index.js").Attribute[] | null;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return (0, get_attr_specs_1.getAttrSpecs)(el.localName, el.namespaceURI, schema);
|
|
1
|
+
import { getAttrSpecs as _getAttrSpecs } from '../specs/get-attr-specs.js';
|
|
2
|
+
export function getAttrSpecs(
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
|
+
el, schema) {
|
|
5
|
+
return _getAttrSpecs(el.localName, el.namespaceURI, schema);
|
|
7
6
|
}
|
|
8
|
-
exports.getAttrSpecs = getAttrSpecs;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types/index.js';
|
|
2
2
|
type ARIAProps = Record<string, ARIAProp>;
|
|
3
3
|
type ARIAProp = {
|
|
4
4
|
name: string;
|
|
@@ -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 {};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
|
|
1
|
+
import { ariaSpecs as _ariaSpecs } from '../specs/aria-specs.js';
|
|
2
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
export function getComputedAriaProps(specs,
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
5
|
+
el, version) {
|
|
6
|
+
const ariaSpecs = _ariaSpecs(specs, version);
|
|
7
|
+
const { role } = getComputedRole(specs, el, version);
|
|
9
8
|
if (!role) {
|
|
10
9
|
return {};
|
|
11
10
|
}
|
|
12
11
|
const props = {};
|
|
13
12
|
role.ownedProperties.forEach(ownedProp => {
|
|
14
|
-
var _a;
|
|
15
13
|
const spec = ariaSpecs.props.find(propSpec => propSpec.name === ownedProp.name);
|
|
16
14
|
if (!spec) {
|
|
17
15
|
return;
|
|
@@ -29,7 +27,7 @@ function getComputedAriaProps(specs, el, version) {
|
|
|
29
27
|
return;
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
|
-
const equivalentHtmlAttr =
|
|
30
|
+
const equivalentHtmlAttr = spec.equivalentHtmlAttrs?.[0];
|
|
33
31
|
if (equivalentHtmlAttr && el.hasAttribute(equivalentHtmlAttr.htmlAttrName)) {
|
|
34
32
|
const value = equivalentHtmlAttr.value === null
|
|
35
33
|
? el.getAttribute(equivalentHtmlAttr.htmlAttrName)
|
|
@@ -62,7 +60,6 @@ function getComputedAriaProps(specs, el, version) {
|
|
|
62
60
|
});
|
|
63
61
|
return props;
|
|
64
62
|
}
|
|
65
|
-
exports.getComputedAriaProps = getComputedAriaProps;
|
|
66
63
|
function isValidAriaValue(spec, role, value, enumList) {
|
|
67
64
|
let type = spec.value;
|
|
68
65
|
if (spec.conditionalValue) {
|
|
@@ -72,7 +69,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
72
69
|
}
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
|
-
value = (value
|
|
72
|
+
value = (value ?? '').trim();
|
|
76
73
|
switch (type) {
|
|
77
74
|
case 'string': {
|
|
78
75
|
return true;
|
|
@@ -88,7 +85,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
88
85
|
}
|
|
89
86
|
case 'token':
|
|
90
87
|
case 'token list': {
|
|
91
|
-
if (
|
|
88
|
+
if (enumList.length === 0) {
|
|
92
89
|
throw new Error('Need an enum list in token and token list types');
|
|
93
90
|
}
|
|
94
91
|
return enumList.includes(value.toLowerCase());
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getComputedRole(specs:
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getComputedRole(specs: MLMLSpec, el: Element, version: ARIAVersion, assumeSingleNode?: boolean): ComputedRole;
|
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const implicitRole =
|
|
15
|
-
const explicitRole =
|
|
16
|
-
const computedRole = explicitRole.role
|
|
1
|
+
import { ariaSpecs } from '../specs/aria-specs.js';
|
|
2
|
+
import { isPresentational } from '../specs/is-presentational.js';
|
|
3
|
+
import { getAccname } from './accname-computation.js';
|
|
4
|
+
import { getAttrSpecs } from './get-attr-specs.js';
|
|
5
|
+
import { getExplicitRole } from './get-explicit-role.js';
|
|
6
|
+
import { getImplicitRole } from './get-implicit-role.js';
|
|
7
|
+
import { getNonPresentationalAncestor } from './get-non-presentational-ancestor.js';
|
|
8
|
+
import { isRequiredOwnedElement } from './has-required-owned-elements.js';
|
|
9
|
+
import { matchesContextRole } from './matches-context-role.js';
|
|
10
|
+
import { mayBeFocusable } from './may-be-focusable.js';
|
|
11
|
+
export function getComputedRole(specs,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
13
|
+
el, version, assumeSingleNode = false) {
|
|
14
|
+
const implicitRole = getImplicitRole(specs, el, version);
|
|
15
|
+
const explicitRole = getExplicitRole(specs, el, version);
|
|
16
|
+
const computedRole = explicitRole.role
|
|
17
|
+
? explicitRole
|
|
18
|
+
: {
|
|
19
|
+
...implicitRole,
|
|
20
|
+
errorType: explicitRole.errorType === 'NO_EXPLICIT' ? undefined : explicitRole.errorType,
|
|
21
|
+
};
|
|
22
|
+
if (assumeSingleNode) {
|
|
23
|
+
return {
|
|
24
|
+
...computedRole,
|
|
25
|
+
errorType: 'NO_OWNER',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
17
28
|
/**
|
|
18
29
|
* Presentational Roles Conflict Resolution
|
|
19
30
|
*
|
|
@@ -39,8 +50,21 @@ function getComputedRole(specs, el, version) {
|
|
|
39
50
|
* However, the presentational role behaves transparently
|
|
40
51
|
* according to the sample code in WAI-ARIA specification.
|
|
41
52
|
*/
|
|
42
|
-
if (
|
|
43
|
-
|
|
53
|
+
if (computedRole.role && computedRole.role.requiredContextRole.length > 0) {
|
|
54
|
+
/**
|
|
55
|
+
* An element fragment that serves as the root without a parent element
|
|
56
|
+
* cannot satisfy the "Required Context Role" condition.
|
|
57
|
+
* Therefore, under normal circumstances, the `role` will disappear.
|
|
58
|
+
* However, in this specific case, it will fall back to both explicit
|
|
59
|
+
* and implicit roles. Note that the explicit role takes precedence.
|
|
60
|
+
*/
|
|
61
|
+
if (el.parentElement === null) {
|
|
62
|
+
return {
|
|
63
|
+
...computedRole,
|
|
64
|
+
errorType: 'NO_OWNER',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
|
|
44
68
|
if (!nonPresentationalAncestor.role) {
|
|
45
69
|
return {
|
|
46
70
|
el,
|
|
@@ -48,7 +72,7 @@ function getComputedRole(specs, el, version) {
|
|
|
48
72
|
errorType: 'NO_OWNER',
|
|
49
73
|
};
|
|
50
74
|
}
|
|
51
|
-
if (!(
|
|
75
|
+
if (!matchesContextRole(computedRole.role.requiredContextRole, el, specs, version)) {
|
|
52
76
|
return {
|
|
53
77
|
el,
|
|
54
78
|
role: null,
|
|
@@ -56,7 +80,53 @@ function getComputedRole(specs, el, version) {
|
|
|
56
80
|
};
|
|
57
81
|
}
|
|
58
82
|
}
|
|
59
|
-
|
|
83
|
+
/**
|
|
84
|
+
* SVG: Including Elements in the Accessibility Tree
|
|
85
|
+
*
|
|
86
|
+
* > Many SVG elements—although rendered to the screen—
|
|
87
|
+
* > do not have an intrinsic semantic meaning. Instead,
|
|
88
|
+
* > they represent components of the visual presentation of the document.
|
|
89
|
+
* > To simplify the accessible representation of the document,
|
|
90
|
+
* > these purely presentational elements should normally be omitted
|
|
91
|
+
* > from the accessibility tree, unless the author explicitly provides semantic content.
|
|
92
|
+
* >
|
|
93
|
+
* > However, any rendered SVG element may have semantic meaning.
|
|
94
|
+
* > Authors indicate the significance of the element
|
|
95
|
+
* > by including alternative text content or WAI-ARIA attributes.
|
|
96
|
+
* > This section defines the rules for including normally-omitted elements
|
|
97
|
+
* > in the accessibility tree.
|
|
98
|
+
* >
|
|
99
|
+
* > The following graphical and container elements
|
|
100
|
+
* > in the SVG namespace SHOULD NOT be included in the accessibility tree,
|
|
101
|
+
* > except as described in this section:
|
|
102
|
+
* >
|
|
103
|
+
* > - shape elements (circle, ellipse, line, path, polygon, polyline, rect)
|
|
104
|
+
* > - the use element
|
|
105
|
+
* > - the grouping (g) element
|
|
106
|
+
* > - the image element
|
|
107
|
+
* > - the mesh element
|
|
108
|
+
* > - text formatting elements (textPath, tspan)
|
|
109
|
+
* > - the foreignObject element
|
|
110
|
+
*
|
|
111
|
+
* @see https://www.w3.org/TR/svg-aam-1.0/#include_elements
|
|
112
|
+
*/
|
|
113
|
+
if (
|
|
114
|
+
// It doesn't been specified a valid explicit role.
|
|
115
|
+
(explicitRole.role === null || explicitRole.errorType != null) &&
|
|
116
|
+
// It is an SVG element.
|
|
117
|
+
el.namespaceURI === 'http://www.w3.org/2000/svg') {
|
|
118
|
+
const accname = getAccname(el).trim() ||
|
|
119
|
+
Array.from(el.children)
|
|
120
|
+
.find(child => ['title', 'desc'].includes(child.localName))
|
|
121
|
+
?.textContent?.trim();
|
|
122
|
+
if (!accname) {
|
|
123
|
+
return {
|
|
124
|
+
el,
|
|
125
|
+
role: null,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (computedRole.role && !isPresentational(computedRole.role.name)) {
|
|
60
130
|
return computedRole;
|
|
61
131
|
}
|
|
62
132
|
/**
|
|
@@ -81,7 +151,7 @@ function getComputedRole(specs, el, version) {
|
|
|
81
151
|
* the interactive elements can not specify the presentational role
|
|
82
152
|
* in the previous processing that computes the permitted role (`getExplicitRole`).
|
|
83
153
|
*/
|
|
84
|
-
|
|
154
|
+
mayBeFocusable(el, specs) &&
|
|
85
155
|
/**
|
|
86
156
|
* 2. No disabled
|
|
87
157
|
*/
|
|
@@ -110,13 +180,13 @@ function getComputedRole(specs, el, version) {
|
|
|
110
180
|
* `role=presentation` is to be ignored absolutely.
|
|
111
181
|
*/
|
|
112
182
|
if (explicitRole.role) {
|
|
113
|
-
const nonPresentationalAncestor =
|
|
114
|
-
if (
|
|
183
|
+
const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
|
|
184
|
+
if (nonPresentationalAncestor.role && nonPresentationalAncestor.role?.requiredOwnedElements.length > 0) {
|
|
115
185
|
if (nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
|
|
116
186
|
// const ancestor = nonPresentationalAncestor.el;
|
|
117
187
|
// const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
|
|
118
188
|
// console.log({ nonPresentationalAncestor, ancestorImplicitRole });
|
|
119
|
-
return (
|
|
189
|
+
return isRequiredOwnedElement(implicitRole.el, implicitRole.role, expected, specs, version);
|
|
120
190
|
})) {
|
|
121
191
|
return {
|
|
122
192
|
...implicitRole,
|
|
@@ -135,9 +205,9 @@ function getComputedRole(specs, el, version) {
|
|
|
135
205
|
* > unless the presentational role is inherited
|
|
136
206
|
* > and an explicit non-presentational role is applied.
|
|
137
207
|
*/
|
|
138
|
-
const { props } =
|
|
208
|
+
const { props } = ariaSpecs(specs, version);
|
|
139
209
|
for (const attr of Array.from(el.attributes)) {
|
|
140
|
-
if (
|
|
210
|
+
if (props.find(p => p.name === attr.name)?.isGlobal) {
|
|
141
211
|
return {
|
|
142
212
|
...implicitRole,
|
|
143
213
|
errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
|
|
@@ -146,20 +216,23 @@ function getComputedRole(specs, el, version) {
|
|
|
146
216
|
}
|
|
147
217
|
return computedRole;
|
|
148
218
|
}
|
|
149
|
-
exports.getComputedRole = getComputedRole;
|
|
150
219
|
/**
|
|
151
220
|
* The attribute is available in its owner element,
|
|
152
221
|
* it has the attribute.
|
|
153
222
|
*/
|
|
154
|
-
function isEnabledAttr(
|
|
155
|
-
|
|
156
|
-
|
|
223
|
+
function isEnabledAttr(
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
225
|
+
el, specs, attrName) {
|
|
226
|
+
const attrs = getAttrSpecs(el, specs);
|
|
227
|
+
const attr = attrs?.find(attr => attr.name === attrName);
|
|
157
228
|
return !!attr && el.hasAttribute(attrName);
|
|
158
229
|
}
|
|
159
230
|
/**
|
|
160
231
|
* Determines whether some ancestors match the condition that the specified callback function.
|
|
161
232
|
*/
|
|
162
|
-
function someAncestors(
|
|
233
|
+
function someAncestors(
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
235
|
+
el, predicate) {
|
|
163
236
|
const list = [];
|
|
164
237
|
let current = el;
|
|
165
238
|
while (current) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { ElementSpec } from '../types';
|
|
2
|
-
|
|
3
|
-
export declare function getContentModel(el: Element, specs:
|
|
1
|
+
import type { ElementSpec } from '../types/index.js';
|
|
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.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentRequire> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentOptional> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentOneOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentZeroOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentChoice> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../types/permitted-structures.js").PermittedContentTransparent>)[] | null;
|
|
4
|
+
export {};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getContentModel = void 0;
|
|
4
|
-
const get_spec_1 = require("./get-spec");
|
|
1
|
+
import { getSpec } from './get-spec.js';
|
|
5
2
|
const cachesBySpecs = new Map();
|
|
6
|
-
function getContentModel(
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export function getContentModel(
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
5
|
+
el, specs) {
|
|
6
|
+
const cacheByEl = cachesBySpecs.get(specs) ?? new Map();
|
|
9
7
|
const cached = cacheByEl.get(el);
|
|
10
|
-
if (cached) {
|
|
8
|
+
if (cached !== undefined) {
|
|
11
9
|
return cached;
|
|
12
10
|
}
|
|
13
|
-
const spec =
|
|
11
|
+
const spec = getSpec(el, specs);
|
|
14
12
|
if (!spec) {
|
|
15
13
|
cacheByEl.set(el, null);
|
|
16
14
|
return null;
|
|
17
15
|
}
|
|
18
|
-
const conditions =
|
|
16
|
+
const conditions = spec.contentModel.conditional ?? [];
|
|
19
17
|
for (const cond of conditions) {
|
|
20
18
|
if (el.matches(cond.condition)) {
|
|
21
19
|
cacheByEl.set(el, cond.contents);
|
|
@@ -25,4 +23,3 @@ function getContentModel(el, specs) {
|
|
|
25
23
|
cacheByEl.set(el, spec.contentModel.contents);
|
|
26
24
|
return spec.contentModel.contents;
|
|
27
25
|
}
|
|
28
|
-
exports.getContentModel = getContentModel;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function getExplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function getExplicitRole(specs, el, version) {
|
|
1
|
+
import { getRoleSpec } from '../specs/get-role-spec.js';
|
|
2
|
+
import { resolveNamespace } from '../utils/resolve-namespace.js';
|
|
3
|
+
import { getPermittedRoles } from './get-permitted-roles.js';
|
|
4
|
+
export function getExplicitRole(specs,
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
6
|
+
el, version) {
|
|
8
7
|
const roleValue = el.getAttribute('role');
|
|
9
|
-
const roleNames =
|
|
10
|
-
const permittedRoles =
|
|
11
|
-
const { namespaceURI } =
|
|
8
|
+
const roleNames = roleValue?.toLowerCase().trim().split(/\s+/g) ?? [];
|
|
9
|
+
const permittedRoles = getPermittedRoles(el, version, specs);
|
|
10
|
+
const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
|
|
12
11
|
let error = 'NO_EXPLICIT';
|
|
13
12
|
/**
|
|
14
13
|
* Resolve from values and **Handling Author Errors**
|
|
@@ -16,7 +15,7 @@ function getExplicitRole(specs, el, version) {
|
|
|
16
15
|
* @see https://w3c.github.io/aria/#document-handling_author-errors
|
|
17
16
|
*/
|
|
18
17
|
for (const roleName of roleNames) {
|
|
19
|
-
const spec =
|
|
18
|
+
const spec = getRoleSpec(specs, roleName, namespaceURI, version);
|
|
20
19
|
/**
|
|
21
20
|
* If `spec` is null, the role DOES NOT EXIST.
|
|
22
21
|
*
|
|
@@ -79,11 +78,12 @@ function getExplicitRole(specs, el, version) {
|
|
|
79
78
|
errorType: error,
|
|
80
79
|
};
|
|
81
80
|
}
|
|
82
|
-
exports.getExplicitRole = getExplicitRole;
|
|
83
81
|
function isLandmarkRole(role) {
|
|
84
|
-
return role
|
|
82
|
+
return role?.superClassRoles.some(su => su.name === 'landmark');
|
|
85
83
|
}
|
|
86
|
-
function isValidLandmarkRole(
|
|
84
|
+
function isValidLandmarkRole(
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
86
|
+
el, role) {
|
|
87
87
|
if (!role.accessibleNameRequired) {
|
|
88
88
|
return true;
|
|
89
89
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(specs:
|
|
3
|
-
export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs:
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
3
|
+
export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("../index.js").ImplicitRole;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function getImplicitRole(specs, el, version) {
|
|
1
|
+
import { getImplicitRole as _getImplicitRole } from '../specs/get-implicit-role.js';
|
|
2
|
+
import { getRoleSpec } from '../specs/get-role-spec.js';
|
|
3
|
+
import { resolveNamespace } from '../utils/resolve-namespace.js';
|
|
4
|
+
export function getImplicitRole(specs,
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
6
|
+
el, version) {
|
|
8
7
|
const implicitRole = getImplicitRoleName(el, version, specs);
|
|
9
8
|
if (implicitRole === false) {
|
|
10
9
|
// No Corresponding Role
|
|
@@ -13,8 +12,8 @@ function getImplicitRole(specs, el, version) {
|
|
|
13
12
|
role: null,
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
const { namespaceURI } =
|
|
17
|
-
const spec =
|
|
15
|
+
const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
|
|
16
|
+
const spec = getRoleSpec(specs, implicitRole, namespaceURI, version);
|
|
18
17
|
if (!spec) {
|
|
19
18
|
return {
|
|
20
19
|
el,
|
|
@@ -30,8 +29,8 @@ function getImplicitRole(specs, el, version) {
|
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
export function getImplicitRoleName(
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
34
|
+
el, version, specs) {
|
|
35
|
+
return _getImplicitRole(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
36
36
|
}
|
|
37
|
-
exports.getImplicitRoleName = getImplicitRoleName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getNonPresentationalAncestor(el: Element, specs: MLMLSpec, version: ARIAVersion): import("../types").ComputedRole | {
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getNonPresentationalAncestor(el: Element, specs: MLMLSpec, version: ARIAVersion): import("../types/index.js").ComputedRole | {
|
|
3
3
|
el: null;
|
|
4
4
|
role: null;
|
|
5
5
|
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function getNonPresentationalAncestor(el, specs, version) {
|
|
7
|
-
var _a;
|
|
1
|
+
import { isPresentational } from '../specs/is-presentational.js';
|
|
2
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
export function getNonPresentationalAncestor(
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
5
|
+
el, specs, version) {
|
|
8
6
|
let ancestor = el.parentElement;
|
|
7
|
+
/**
|
|
8
|
+
* In ARIA 1.1 and 1.2, the role of an element is not affected by the role of its ancestor elements.
|
|
9
|
+
*
|
|
10
|
+
* It is due to implementation considerations in Markuplint.
|
|
11
|
+
*/
|
|
12
|
+
const assumeSingleNode = version !== '1.1' && version !== '1.2';
|
|
9
13
|
while (ancestor) {
|
|
10
|
-
const ancestorRole =
|
|
11
|
-
if (!
|
|
14
|
+
const ancestorRole = getComputedRole(specs, ancestor, version, assumeSingleNode);
|
|
15
|
+
if (!isPresentational(ancestorRole.role?.name)) {
|
|
12
16
|
return ancestorRole;
|
|
13
17
|
}
|
|
14
18
|
ancestor = ancestor.parentElement;
|
|
@@ -18,4 +22,3 @@ function getNonPresentationalAncestor(el, specs, version) {
|
|
|
18
22
|
role: null,
|
|
19
23
|
};
|
|
20
24
|
}
|
|
21
|
-
exports.getNonPresentationalAncestor = getNonPresentationalAncestor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs:
|
|
3
|
-
name: string;
|
|
4
|
-
deprecated?: boolean | undefined;
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: MLMLSpec): readonly {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly deprecated?: boolean | undefined;
|
|
5
5
|
}[];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return (0, get_permitted_roles_1.getPermittedRoles)(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
1
|
+
import { getPermittedRoles as _getPermittedRoles } from '../specs/get-permitted-roles.js';
|
|
2
|
+
export function getPermittedRoles(
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
|
+
el, version, specs) {
|
|
5
|
+
return _getPermittedRoles(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
7
6
|
}
|
|
8
|
-
exports.getPermittedRoles = getPermittedRoles;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
|
|
1
|
+
import type { ElementSpec } from '../types/index.js';
|
|
2
|
+
export declare function getSpec<K extends keyof ElementSpec>(el: Element, specs: readonly Pick<ElementSpec, 'name' | K>[]): Pick<ElementSpec, "name" | K> | null;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return (0, get_spec_by_tag_name_1.getSpecByTagName)(specs, el.localName, el.namespaceURI);
|
|
1
|
+
import { getSpecByTagName } from '../specs/get-spec-by-tag-name.js';
|
|
2
|
+
export function getSpec(
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
|
+
el, specs) {
|
|
5
|
+
return getSpecByTagName(specs, el.localName, el.namespaceURI);
|
|
7
6
|
}
|
|
8
|
-
exports.getSpec = getSpec;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function hasRequiredOwnedElement(el: Element, specs:
|
|
3
|
-
export declare function isRequiredOwnedElement(
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
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;
|