@markuplint/ml-spec 3.14.0 → 4.0.0-alpha.10
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/LICENSE +1 -1
- package/lib/constant/aria-version.d.ts +2 -2
- package/lib/constant/aria-version.js +2 -5
- package/lib/dom-traverse/accname-computation.js +4 -7
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
- package/lib/dom-traverse/get-attr-specs.js +3 -7
- package/lib/dom-traverse/get-computed-aria-props.d.ts +6 -6
- package/lib/dom-traverse/get-computed-aria-props.js +13 -18
- package/lib/dom-traverse/get-computed-role.d.ts +2 -7
- package/lib/dom-traverse/get-computed-role.js +33 -39
- package/lib/dom-traverse/get-content-model.d.ts +2 -27
- package/lib/dom-traverse/get-content-model.js +5 -10
- package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
- package/lib/dom-traverse/get-explicit-role.js +9 -14
- package/lib/dom-traverse/get-implicit-role.d.ts +2 -6
- package/lib/dom-traverse/get-implicit-role.js +8 -13
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +5 -11
- package/lib/dom-traverse/get-non-presentational-ancestor.js +5 -10
- package/lib/dom-traverse/get-permitted-roles.d.ts +4 -8
- package/lib/dom-traverse/get-permitted-roles.js +3 -7
- package/lib/dom-traverse/get-spec.d.ts +2 -5
- package/lib/dom-traverse/get-spec.js +3 -7
- package/lib/dom-traverse/has-required-owned-elements.d.ts +2 -8
- package/lib/dom-traverse/has-required-owned-elements.js +13 -20
- package/lib/dom-traverse/is-exposed.d.ts +1 -1
- package/lib/dom-traverse/is-exposed.js +17 -24
- package/lib/dom-traverse/matches-context-role.d.ts +2 -7
- package/lib/dom-traverse/matches-context-role.js +5 -9
- package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
- package/lib/dom-traverse/may-be-focusable.js +3 -7
- package/lib/index.d.ts +28 -28
- package/lib/index.js +28 -33
- package/lib/specs/aria-specs.d.ts +5 -8
- package/lib/specs/aria-specs.js +1 -5
- package/lib/specs/content-model-category-to-tag-names.d.ts +3 -6
- package/lib/specs/content-model-category-to-tag-names.js +1 -5
- package/lib/specs/get-aria.d.ts +3 -9
- package/lib/specs/get-aria.js +11 -17
- package/lib/specs/get-attr-specs.d.ts +4 -8
- package/lib/specs/get-attr-specs.js +6 -11
- package/lib/specs/get-implicit-role.d.ts +2 -8
- package/lib/specs/get-implicit-role.js +3 -7
- package/lib/specs/get-permitted-roles.d.ts +4 -10
- package/lib/specs/get-permitted-roles.js +14 -17
- package/lib/specs/get-role-spec.d.ts +4 -11
- package/lib/specs/get-role-spec.js +10 -14
- package/lib/specs/get-selectors-by-content-model-category.d.ts +2 -2
- package/lib/specs/get-selectors-by-content-model-category.js +2 -6
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -6
- package/lib/specs/get-spec-by-tag-name.js +4 -9
- package/lib/specs/is-nothing-content-model.js +3 -7
- package/lib/specs/is-palpable-elements.d.ts +5 -9
- package/lib/specs/is-palpable-elements.js +5 -10
- package/lib/specs/is-presentational.js +1 -5
- package/lib/specs/is-void-element.d.ts +3 -1
- package/lib/specs/is-void-element.js +4 -10
- package/lib/specs/resolve-version.d.ts +3 -6
- 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 +20 -25
- package/lib/types/aria.d.ts +133 -147
- package/lib/types/aria.js +1 -2
- package/lib/types/attributes.d.ts +110 -1504
- package/lib/types/attributes.js +1 -2
- package/lib/types/index.d.ts +149 -177
- package/lib/types/index.js +1 -2
- package/lib/types/permitted-structures.d.ts +35 -74
- package/lib/types/permitted-structures.js +1 -2
- package/lib/utils/get-ns.js +1 -5
- package/lib/utils/merge-array.d.ts +4 -9
- package/lib/utils/merge-array.js +2 -6
- package/lib/utils/resolve-namespace.d.ts +4 -4
- package/lib/utils/resolve-namespace.js +4 -9
- package/lib/utils/{validateAriaVersion.d.ts → validate-aria-version.d.ts} +1 -1
- package/lib/utils/validate-aria-version.js +4 -0
- package/package.json +20 -14
- package/lib/utils/validateAriaVersion.js +0 -8
- package/test/dom-traverse/accname-computation.spec.js +0 -69
- package/test/dom-traverse/get-computed-aria-props.spec.js +0 -758
- package/test/dom-traverse/get-computed-role.spec.js +0 -315
- package/test/dom-traverse/get-implicit-role.spec.js +0 -40
- package/test/dom-traverse/has-required-owned-elements.spec.js +0 -34
- package/test/dom-traverse/is-exposed.spec.js +0 -70
- package/test/dom-traverse/matches-context-role.spec.js +0 -60
- package/test/specs/get-attr-specs.spec.js +0 -41
- package/test/specs/get-implicit-role.spec.js +0 -79
- package/test/specs/get-permitted-roles.spec.js +0 -418
- package/test/specs/get-role-spec.spec.js +0 -67
- package/test/specs/get-spec-by-tag-name.spec.js +0 -68
- package/test/specs/resolve-version.spec.js +0 -34
- package/test/specs/schema-to-spec.spec.js +0 -61
- package/test/utils/resolve-namespace.spec.js +0 -37
package/LICENSE
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const ariaVersions: readonly [
|
|
2
|
-
export declare const ARIA_RECOMMENDED_VERSION:
|
|
1
|
+
export declare const ariaVersions: readonly ["1.1", "1.2", "1.3"];
|
|
2
|
+
export declare const ARIA_RECOMMENDED_VERSION: "1.2";
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ARIA_RECOMMENDED_VERSION = exports.ariaVersions = void 0;
|
|
4
|
-
exports.ariaVersions = ['1.1', '1.2', '1.3'];
|
|
5
|
-
exports.ARIA_RECOMMENDED_VERSION = '1.2';
|
|
1
|
+
export const ariaVersions = ['1.1', '1.2', '1.3'];
|
|
2
|
+
export const ARIA_RECOMMENDED_VERSION = '1.2';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const dom_accessibility_api_1 = require("dom-accessibility-api");
|
|
5
|
-
function getAccname(
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { computeAccessibleName } from 'dom-accessibility-api';
|
|
3
|
+
export function getAccname(
|
|
6
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
5
|
el) {
|
|
8
|
-
return
|
|
6
|
+
return computeAccessibleName(el);
|
|
9
7
|
}
|
|
10
|
-
exports.getAccname = getAccname;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import(
|
|
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,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getAttrSpecs = void 0;
|
|
4
|
-
const get_attr_specs_1 = require("../specs/get-attr-specs");
|
|
5
|
-
function getAttrSpecs(
|
|
1
|
+
import { getAttrSpecs as _getAttrSpecs } from '../specs/get-attr-specs.js';
|
|
2
|
+
export function getAttrSpecs(
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
el, schema) {
|
|
8
|
-
return (
|
|
5
|
+
return _getAttrSpecs(el.localName, el.namespaceURI, schema);
|
|
9
6
|
}
|
|
10
|
-
exports.getAttrSpecs = getAttrSpecs;
|
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
|
|
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
11
|
export declare function getComputedAriaProps(specs: MLMLSpec, el: Element, version: ARIAVersion): ARIAProps;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const aria_specs_1 = require("../specs/aria-specs");
|
|
5
|
-
const get_computed_role_1 = require("./get-computed-role");
|
|
6
|
-
function getComputedAriaProps(specs,
|
|
1
|
+
import { ariaSpecs as _ariaSpecs } from '../specs/aria-specs.js';
|
|
2
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
export function getComputedAriaProps(specs,
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
5
|
el, version) {
|
|
9
|
-
const ariaSpecs = (
|
|
10
|
-
const { role } =
|
|
6
|
+
const ariaSpecs = _ariaSpecs(specs, version);
|
|
7
|
+
const { role } = getComputedRole(specs, el, version);
|
|
11
8
|
if (!role) {
|
|
12
9
|
return {};
|
|
13
10
|
}
|
|
14
11
|
const props = {};
|
|
15
|
-
role.ownedProperties
|
|
16
|
-
var _a;
|
|
12
|
+
for (const ownedProp of role.ownedProperties) {
|
|
17
13
|
const spec = ariaSpecs.props.find(propSpec => propSpec.name === ownedProp.name);
|
|
18
14
|
if (!spec) {
|
|
19
|
-
|
|
15
|
+
continue;
|
|
20
16
|
}
|
|
21
17
|
if (el.hasAttribute(spec.name)) {
|
|
22
18
|
const attrValue = el.getAttribute(spec.name);
|
|
@@ -28,10 +24,10 @@ el, version) {
|
|
|
28
24
|
required: !!ownedProp.required,
|
|
29
25
|
from: 'aria-attr',
|
|
30
26
|
};
|
|
31
|
-
|
|
27
|
+
continue;
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
|
-
const equivalentHtmlAttr =
|
|
30
|
+
const equivalentHtmlAttr = spec.equivalentHtmlAttrs?.[0];
|
|
35
31
|
if (equivalentHtmlAttr && el.hasAttribute(equivalentHtmlAttr.htmlAttrName)) {
|
|
36
32
|
const value = equivalentHtmlAttr.value === null
|
|
37
33
|
? el.getAttribute(equivalentHtmlAttr.htmlAttrName)
|
|
@@ -44,7 +40,7 @@ el, version) {
|
|
|
44
40
|
required: !!ownedProp.required,
|
|
45
41
|
from: 'html-attr',
|
|
46
42
|
};
|
|
47
|
-
|
|
43
|
+
continue;
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
let defaultValue = spec.defaultValue;
|
|
@@ -61,10 +57,9 @@ el, version) {
|
|
|
61
57
|
required: !!ownedProp.required,
|
|
62
58
|
from: 'default',
|
|
63
59
|
};
|
|
64
|
-
}
|
|
60
|
+
}
|
|
65
61
|
return props;
|
|
66
62
|
}
|
|
67
|
-
exports.getComputedAriaProps = getComputedAriaProps;
|
|
68
63
|
function isValidAriaValue(spec, role, value, enumList) {
|
|
69
64
|
let type = spec.value;
|
|
70
65
|
if (spec.conditionalValue) {
|
|
@@ -74,7 +69,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
74
69
|
}
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
|
-
value = (value
|
|
72
|
+
value = (value ?? '').trim();
|
|
78
73
|
switch (type) {
|
|
79
74
|
case 'string': {
|
|
80
75
|
return true;
|
|
@@ -86,7 +81,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
86
81
|
}
|
|
87
82
|
case 'integer':
|
|
88
83
|
case 'number': {
|
|
89
|
-
return !isNaN(parseFloat(value));
|
|
84
|
+
return !Number.isNaN(Number.parseFloat(value));
|
|
90
85
|
}
|
|
91
86
|
case 'token':
|
|
92
87
|
case 'token list': {
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getComputedRole(
|
|
3
|
-
specs: MLMLSpec,
|
|
4
|
-
el: Element,
|
|
5
|
-
version: ARIAVersion,
|
|
6
|
-
assumeSingleNode?: boolean,
|
|
7
|
-
): ComputedRole;
|
|
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,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const matches_context_role_1 = require("./matches-context-role");
|
|
13
|
-
const may_be_focusable_1 = require("./may-be-focusable");
|
|
14
|
-
function getComputedRole(specs,
|
|
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,
|
|
15
12
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
16
13
|
el, version, assumeSingleNode = false) {
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
|
|
14
|
+
const implicitRole = getImplicitRole(specs, el, version);
|
|
15
|
+
const explicitRole = getExplicitRole(specs, el, version);
|
|
20
16
|
const computedRole = explicitRole.role
|
|
21
17
|
? explicitRole
|
|
22
18
|
: {
|
|
@@ -68,7 +64,7 @@ el, version, assumeSingleNode = false) {
|
|
|
68
64
|
errorType: 'NO_OWNER',
|
|
69
65
|
};
|
|
70
66
|
}
|
|
71
|
-
const nonPresentationalAncestor =
|
|
67
|
+
const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
|
|
72
68
|
if (!nonPresentationalAncestor.role) {
|
|
73
69
|
return {
|
|
74
70
|
el,
|
|
@@ -76,7 +72,7 @@ el, version, assumeSingleNode = false) {
|
|
|
76
72
|
errorType: 'NO_OWNER',
|
|
77
73
|
};
|
|
78
74
|
}
|
|
79
|
-
if (!
|
|
75
|
+
if (!matchesContextRole(computedRole.role.requiredContextRole, el, specs, version)) {
|
|
80
76
|
return {
|
|
81
77
|
el,
|
|
82
78
|
role: null,
|
|
@@ -119,9 +115,8 @@ el, version, assumeSingleNode = false) {
|
|
|
119
115
|
(explicitRole.role === null || explicitRole.errorType != null) &&
|
|
120
116
|
// It is an SVG element.
|
|
121
117
|
el.namespaceURI === 'http://www.w3.org/2000/svg') {
|
|
122
|
-
const accname =
|
|
123
|
-
(
|
|
124
|
-
.find(child => ['title', 'desc'].includes(child.localName))) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim());
|
|
118
|
+
const accname = getAccname(el).trim() ||
|
|
119
|
+
[...el.children].find(child => ['title', 'desc'].includes(child.localName))?.textContent?.trim();
|
|
125
120
|
if (!accname) {
|
|
126
121
|
return {
|
|
127
122
|
el,
|
|
@@ -129,7 +124,7 @@ el, version, assumeSingleNode = false) {
|
|
|
129
124
|
};
|
|
130
125
|
}
|
|
131
126
|
}
|
|
132
|
-
if (computedRole.role && !
|
|
127
|
+
if (computedRole.role && !isPresentational(computedRole.role.name)) {
|
|
133
128
|
return computedRole;
|
|
134
129
|
}
|
|
135
130
|
/**
|
|
@@ -154,7 +149,7 @@ el, version, assumeSingleNode = false) {
|
|
|
154
149
|
* the interactive elements can not specify the presentational role
|
|
155
150
|
* in the previous processing that computes the permitted role (`getExplicitRole`).
|
|
156
151
|
*/
|
|
157
|
-
|
|
152
|
+
mayBeFocusable(el, specs) &&
|
|
158
153
|
/**
|
|
159
154
|
* 2. No disabled
|
|
160
155
|
*/
|
|
@@ -183,19 +178,19 @@ el, version, assumeSingleNode = false) {
|
|
|
183
178
|
* `role=presentation` is to be ignored absolutely.
|
|
184
179
|
*/
|
|
185
180
|
if (explicitRole.role) {
|
|
186
|
-
const nonPresentationalAncestor =
|
|
187
|
-
if (nonPresentationalAncestor.role &&
|
|
188
|
-
|
|
181
|
+
const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
|
|
182
|
+
if (nonPresentationalAncestor.role &&
|
|
183
|
+
nonPresentationalAncestor.role?.requiredOwnedElements.length > 0 &&
|
|
184
|
+
nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
|
|
189
185
|
// const ancestor = nonPresentationalAncestor.el;
|
|
190
186
|
// const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
|
|
191
187
|
// console.log({ nonPresentationalAncestor, ancestorImplicitRole });
|
|
192
|
-
return
|
|
188
|
+
return isRequiredOwnedElement(implicitRole.el, implicitRole.role, expected, specs, version);
|
|
193
189
|
})) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
190
|
+
return {
|
|
191
|
+
...implicitRole,
|
|
192
|
+
errorType: 'REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL',
|
|
193
|
+
};
|
|
199
194
|
}
|
|
200
195
|
}
|
|
201
196
|
/**
|
|
@@ -208,9 +203,9 @@ el, version, assumeSingleNode = false) {
|
|
|
208
203
|
* > unless the presentational role is inherited
|
|
209
204
|
* > and an explicit non-presentational role is applied.
|
|
210
205
|
*/
|
|
211
|
-
const { props } =
|
|
212
|
-
for (const attr of
|
|
213
|
-
if (
|
|
206
|
+
const { props } = ariaSpecs(specs, version);
|
|
207
|
+
for (const attr of el.attributes) {
|
|
208
|
+
if (props.find(p => p.name === attr.name)?.isGlobal) {
|
|
214
209
|
return {
|
|
215
210
|
...implicitRole,
|
|
216
211
|
errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
|
|
@@ -219,7 +214,6 @@ el, version, assumeSingleNode = false) {
|
|
|
219
214
|
}
|
|
220
215
|
return computedRole;
|
|
221
216
|
}
|
|
222
|
-
exports.getComputedRole = getComputedRole;
|
|
223
217
|
/**
|
|
224
218
|
* The attribute is available in its owner element,
|
|
225
219
|
* it has the attribute.
|
|
@@ -227,8 +221,8 @@ exports.getComputedRole = getComputedRole;
|
|
|
227
221
|
function isEnabledAttr(
|
|
228
222
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
229
223
|
el, specs, attrName) {
|
|
230
|
-
const attrs =
|
|
231
|
-
const attr = attrs
|
|
224
|
+
const attrs = getAttrSpecs(el, specs);
|
|
225
|
+
const attr = attrs?.find(attr => attr.name === attrName);
|
|
232
226
|
return !!attr && el.hasAttribute(attrName);
|
|
233
227
|
}
|
|
234
228
|
/**
|
|
@@ -1,29 +1,4 @@
|
|
|
1
|
-
import type { ElementSpec } from '../types';
|
|
1
|
+
import type { ElementSpec } from '../types/index.js';
|
|
2
2
|
type Specs = readonly Pick<ElementSpec, 'name' | 'contentModel'>[];
|
|
3
|
-
export declare function getContentModel(
|
|
4
|
-
el: Element,
|
|
5
|
-
specs: Specs,
|
|
6
|
-
):
|
|
7
|
-
| boolean
|
|
8
|
-
| readonly (
|
|
9
|
-
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
10
|
-
import('../types/permitted-structures').PermittedContentRequire
|
|
11
|
-
>
|
|
12
|
-
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
13
|
-
import('../types/permitted-structures').PermittedContentOptional
|
|
14
|
-
>
|
|
15
|
-
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
16
|
-
import('../types/permitted-structures').PermittedContentOneOrMore
|
|
17
|
-
>
|
|
18
|
-
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
19
|
-
import('../types/permitted-structures').PermittedContentZeroOrMore
|
|
20
|
-
>
|
|
21
|
-
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
22
|
-
import('../types/permitted-structures').PermittedContentChoice
|
|
23
|
-
>
|
|
24
|
-
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
25
|
-
import('../types/permitted-structures').PermittedContentTransparent
|
|
26
|
-
>
|
|
27
|
-
)[]
|
|
28
|
-
| null;
|
|
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;
|
|
29
4
|
export {};
|
|
@@ -1,23 +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(
|
|
3
|
+
export function getContentModel(
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
5
|
el, specs) {
|
|
9
|
-
|
|
10
|
-
const cacheByEl = (_a = cachesBySpecs.get(specs)) !== null && _a !== void 0 ? _a : new Map();
|
|
6
|
+
const cacheByEl = cachesBySpecs.get(specs) ?? new Map();
|
|
11
7
|
const cached = cacheByEl.get(el);
|
|
12
8
|
if (cached !== undefined) {
|
|
13
9
|
return cached;
|
|
14
10
|
}
|
|
15
|
-
const spec =
|
|
11
|
+
const spec = getSpec(el, specs);
|
|
16
12
|
if (!spec) {
|
|
17
13
|
cacheByEl.set(el, null);
|
|
18
14
|
return null;
|
|
19
15
|
}
|
|
20
|
-
const conditions =
|
|
16
|
+
const conditions = spec.contentModel.conditional ?? [];
|
|
21
17
|
for (const cond of conditions) {
|
|
22
18
|
if (el.matches(cond.condition)) {
|
|
23
19
|
cacheByEl.set(el, cond.contents);
|
|
@@ -27,4 +23,3 @@ el, specs) {
|
|
|
27
23
|
cacheByEl.set(el, spec.contentModel.contents);
|
|
28
24
|
return spec.contentModel.contents;
|
|
29
25
|
}
|
|
30
|
-
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,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
6
|
-
const get_permitted_roles_1 = require("./get-permitted-roles");
|
|
7
|
-
function getExplicitRole(specs,
|
|
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,
|
|
8
5
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
6
|
el, version) {
|
|
10
|
-
var _a;
|
|
11
7
|
const roleValue = el.getAttribute('role');
|
|
12
|
-
const roleNames =
|
|
13
|
-
const permittedRoles =
|
|
14
|
-
const { namespaceURI } =
|
|
8
|
+
const roleNames = roleValue?.toLowerCase().trim().split(/\s+/) ?? [];
|
|
9
|
+
const permittedRoles = getPermittedRoles(el, version, specs);
|
|
10
|
+
const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
|
|
15
11
|
let error = 'NO_EXPLICIT';
|
|
16
12
|
/**
|
|
17
13
|
* Resolve from values and **Handling Author Errors**
|
|
@@ -19,7 +15,7 @@ el, version) {
|
|
|
19
15
|
* @see https://w3c.github.io/aria/#document-handling_author-errors
|
|
20
16
|
*/
|
|
21
17
|
for (const roleName of roleNames) {
|
|
22
|
-
const spec =
|
|
18
|
+
const spec = getRoleSpec(specs, roleName, namespaceURI, version);
|
|
23
19
|
/**
|
|
24
20
|
* If `spec` is null, the role DOES NOT EXIST.
|
|
25
21
|
*
|
|
@@ -82,9 +78,8 @@ el, version) {
|
|
|
82
78
|
errorType: error,
|
|
83
79
|
};
|
|
84
80
|
}
|
|
85
|
-
exports.getExplicitRole = getExplicitRole;
|
|
86
81
|
function isLandmarkRole(role) {
|
|
87
|
-
return role
|
|
82
|
+
return role?.superClassRoles.some(su => su.name === 'landmark');
|
|
88
83
|
}
|
|
89
84
|
function isValidLandmarkRole(
|
|
90
85
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
3
|
-
export declare function getImplicitRoleName(
|
|
4
|
-
el: Element,
|
|
5
|
-
version: ARIAVersion,
|
|
6
|
-
specs: MLMLSpec,
|
|
7
|
-
): import('..').ImplicitRole;
|
|
3
|
+
export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): import("../index.js").ImplicitRole;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const get_role_spec_1 = require("../specs/get-role-spec");
|
|
6
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
7
|
-
function getImplicitRole(specs,
|
|
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,
|
|
8
5
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
6
|
el, version) {
|
|
10
7
|
const implicitRole = getImplicitRoleName(el, version, specs);
|
|
@@ -15,8 +12,8 @@ el, version) {
|
|
|
15
12
|
role: null,
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
|
-
const { namespaceURI } =
|
|
19
|
-
const spec =
|
|
15
|
+
const { namespaceURI } = resolveNamespace(el.localName, el.namespaceURI);
|
|
16
|
+
const spec = getRoleSpec(specs, implicitRole, namespaceURI, version);
|
|
20
17
|
if (!spec) {
|
|
21
18
|
return {
|
|
22
19
|
el,
|
|
@@ -32,10 +29,8 @@ el, version) {
|
|
|
32
29
|
},
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
|
-
|
|
36
|
-
function getImplicitRoleName(
|
|
32
|
+
export function getImplicitRoleName(
|
|
37
33
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
38
34
|
el, version, specs) {
|
|
39
|
-
return (
|
|
35
|
+
return _getImplicitRole(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
40
36
|
}
|
|
41
|
-
exports.getImplicitRoleName = getImplicitRoleName;
|
|
@@ -1,11 +1,5 @@
|
|
|
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
|
-
};
|
|
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
|
+
el: null;
|
|
4
|
+
role: null;
|
|
5
|
+
};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const is_presentational_1 = require("../specs/is-presentational");
|
|
5
|
-
const get_computed_role_1 = require("./get-computed-role");
|
|
6
|
-
function getNonPresentationalAncestor(
|
|
1
|
+
import { isPresentational } from '../specs/is-presentational.js';
|
|
2
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
export function getNonPresentationalAncestor(
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
5
|
el, specs, version) {
|
|
9
|
-
var _a;
|
|
10
6
|
let ancestor = el.parentElement;
|
|
11
7
|
/**
|
|
12
8
|
* In ARIA 1.1 and 1.2, the role of an element is not affected by the role of its ancestor elements.
|
|
@@ -15,8 +11,8 @@ el, specs, version) {
|
|
|
15
11
|
*/
|
|
16
12
|
const assumeSingleNode = version !== '1.1' && version !== '1.2';
|
|
17
13
|
while (ancestor) {
|
|
18
|
-
const ancestorRole =
|
|
19
|
-
if (!
|
|
14
|
+
const ancestorRole = getComputedRole(specs, ancestor, version, assumeSingleNode);
|
|
15
|
+
if (!isPresentational(ancestorRole.role?.name)) {
|
|
20
16
|
return ancestorRole;
|
|
21
17
|
}
|
|
22
18
|
ancestor = ancestor.parentElement;
|
|
@@ -26,4 +22,3 @@ el, specs, version) {
|
|
|
26
22
|
role: null,
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
|
-
exports.getNonPresentationalAncestor = getNonPresentationalAncestor;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getPermittedRoles(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
specs: MLMLSpec,
|
|
6
|
-
): readonly {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly 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;
|
|
9
5
|
}[];
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getPermittedRoles = void 0;
|
|
4
|
-
const get_permitted_roles_1 = require("../specs/get-permitted-roles");
|
|
5
|
-
function getPermittedRoles(
|
|
1
|
+
import { getPermittedRoles as _getPermittedRoles } from '../specs/get-permitted-roles.js';
|
|
2
|
+
export function getPermittedRoles(
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
el, version, specs) {
|
|
8
|
-
return (
|
|
5
|
+
return _getPermittedRoles(specs, el.localName, el.namespaceURI, version, el.matches.bind(el));
|
|
9
6
|
}
|
|
10
|
-
exports.getPermittedRoles = getPermittedRoles;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpec<K extends keyof ElementSpec>(
|
|
3
|
-
el: Element,
|
|
4
|
-
specs: readonly Pick<ElementSpec, 'name' | K>[],
|
|
5
|
-
): 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,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getSpec = void 0;
|
|
4
|
-
const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
|
|
5
|
-
function getSpec(
|
|
1
|
+
import { getSpecByTagName } from '../specs/get-spec-by-tag-name.js';
|
|
2
|
+
export function getSpec(
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
el, specs) {
|
|
8
|
-
return
|
|
5
|
+
return getSpecByTagName(specs, el.localName, el.namespaceURI);
|
|
9
6
|
}
|
|
10
|
-
exports.getSpec = getSpec;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
3
|
-
export declare function isRequiredOwnedElement(
|
|
4
|
-
el: Element,
|
|
5
|
-
role: ComputedRole['role'],
|
|
6
|
-
query: string,
|
|
7
|
-
specs: MLMLSpec,
|
|
8
|
-
version: ARIAVersion,
|
|
9
|
-
): boolean;
|
|
3
|
+
export declare function isRequiredOwnedElement(el: Element, role: ComputedRole['role'], query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
|