@markuplint/ml-spec 3.10.0 → 4.0.0-alpha.1
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.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 +1 -1
- package/lib/dom-traverse/get-computed-aria-props.js +7 -12
- package/lib/dom-traverse/get-computed-role.d.ts +1 -1
- package/lib/dom-traverse/get-computed-role.js +70 -28
- package/lib/dom-traverse/get-content-model.d.ts +2 -2
- 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 -2
- package/lib/dom-traverse/get-implicit-role.js +8 -13
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.js +5 -10
- package/lib/dom-traverse/get-permitted-roles.d.ts +1 -1
- package/lib/dom-traverse/get-permitted-roles.js +3 -7
- package/lib/dom-traverse/get-spec.d.ts +1 -1
- package/lib/dom-traverse/get-spec.js +3 -7
- package/lib/dom-traverse/has-required-owned-elements.d.ts +1 -1
- package/lib/dom-traverse/has-required-owned-elements.js +12 -19
- package/lib/dom-traverse/is-exposed.d.ts +1 -1
- package/lib/dom-traverse/is-exposed.js +15 -22
- package/lib/dom-traverse/matches-context-role.d.ts +1 -1
- package/lib/dom-traverse/matches-context-role.js +4 -8
- 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 +4 -4
- 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 +2 -2
- package/lib/specs/get-aria.js +10 -16
- package/lib/specs/get-attr-specs.d.ts +1 -1
- package/lib/specs/get-attr-specs.js +4 -9
- 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 +1 -1
- package/lib/specs/get-permitted-roles.js +14 -17
- package/lib/specs/get-role-spec.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/lib/specs/is-palpable-elements.js +5 -10
- package/lib/specs/is-presentational.js +1 -5
- package/lib/specs/is-void-element.js +1 -5
- package/lib/specs/resolve-version.d.ts +2 -2
- package/lib/specs/resolve-version.js +7 -12
- package/lib/specs/schema-to-spec.d.ts +3 -3
- package/lib/specs/schema-to-spec.js +18 -23
- package/lib/types/aria.js +1 -2
- package/lib/types/attributes.d.ts +1 -1
- package/lib/types/attributes.js +1 -2
- package/lib/types/index.d.ts +4 -4
- package/lib/types/index.js +1 -2
- package/lib/types/permitted-structures.js +1 -2
- package/lib/utils/get-ns.js +1 -5
- package/lib/utils/merge-array.js +1 -5
- package/lib/utils/resolve-namespace.js +4 -9
- package/lib/utils/validateAriaVersion.d.ts +1 -1
- package/lib/utils/validateAriaVersion.js +3 -7
- package/package.json +13 -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 -294
- 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
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const is_presentational_1 = require("../specs/is-presentational");
|
|
7
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
8
|
-
const get_computed_role_1 = require("./get-computed-role");
|
|
1
|
+
import { ariaSpecs } from '../specs/aria-specs.js';
|
|
2
|
+
import { getSpecByTagName } from '../specs/get-spec-by-tag-name.js';
|
|
3
|
+
import { isPresentational } from '../specs/is-presentational.js';
|
|
4
|
+
import { resolveNamespace } from '../utils/resolve-namespace.js';
|
|
5
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
9
6
|
/**
|
|
10
7
|
* Detect including/excluding from the Accessibility Tree
|
|
11
8
|
*
|
|
@@ -15,7 +12,7 @@ const get_computed_role_1 = require("./get-computed-role");
|
|
|
15
12
|
* @param el
|
|
16
13
|
* @param version
|
|
17
14
|
*/
|
|
18
|
-
function isExposed(
|
|
15
|
+
export function isExposed(
|
|
19
16
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
20
17
|
el, specs, version) {
|
|
21
18
|
// According to WAI-ARIA
|
|
@@ -23,8 +20,8 @@ el, specs, version) {
|
|
|
23
20
|
return false;
|
|
24
21
|
}
|
|
25
22
|
// Return true if the element is unknown, deprecated, or obsolete.
|
|
26
|
-
const { localName, namespace } =
|
|
27
|
-
const spec =
|
|
23
|
+
const { localName, namespace } = resolveNamespace(el.localName, el.namespaceURI);
|
|
24
|
+
const spec = getSpecByTagName(specs.specs, localName, namespace);
|
|
28
25
|
if (!spec || spec.deprecated || spec.obsolete != null) {
|
|
29
26
|
return true;
|
|
30
27
|
}
|
|
@@ -44,7 +41,6 @@ el, specs, version) {
|
|
|
44
41
|
// Default
|
|
45
42
|
return true;
|
|
46
43
|
}
|
|
47
|
-
exports.isExposed = isExposed;
|
|
48
44
|
/**
|
|
49
45
|
* Excluding Elements from the Accessibility Tree
|
|
50
46
|
*
|
|
@@ -57,7 +53,6 @@ exports.isExposed = isExposed;
|
|
|
57
53
|
function isExcluding(
|
|
58
54
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
59
55
|
el, specs, version) {
|
|
60
|
-
var _a;
|
|
61
56
|
/**
|
|
62
57
|
* The following elements are not exposed via the accessibility API and
|
|
63
58
|
* user agents MUST NOT include them in the accessibility tree:
|
|
@@ -82,7 +77,7 @@ el, specs, version) {
|
|
|
82
77
|
* These exceptions and conditions are documented in the presentation (role)
|
|
83
78
|
* section.
|
|
84
79
|
*/
|
|
85
|
-
if (
|
|
80
|
+
if (isPresentational((el.getAttribute('role') ?? '').split(/\s+/)[0])) {
|
|
86
81
|
return true;
|
|
87
82
|
}
|
|
88
83
|
/**
|
|
@@ -113,8 +108,8 @@ el, specs, version) {
|
|
|
113
108
|
{
|
|
114
109
|
let currentEl = el.parentElement;
|
|
115
110
|
while (currentEl) {
|
|
116
|
-
const { role } =
|
|
117
|
-
if (role
|
|
111
|
+
const { role } = getComputedRole(specs, currentEl, version);
|
|
112
|
+
if (role?.childrenPresentational) {
|
|
118
113
|
return true;
|
|
119
114
|
}
|
|
120
115
|
currentEl = currentEl.parentElement;
|
|
@@ -163,8 +158,8 @@ el, specs, version) {
|
|
|
163
158
|
* additional guidance on aria-hidden.)
|
|
164
159
|
*/
|
|
165
160
|
if (el.getAttribute('aria-hidden') !== 'true') {
|
|
166
|
-
const globalAria =
|
|
167
|
-
const { role } =
|
|
161
|
+
const globalAria = ariaSpecs(specs, version).props.filter(prop => prop.isGlobal);
|
|
162
|
+
const { role } = getComputedRole(specs, el, version);
|
|
168
163
|
// Has an explicit role
|
|
169
164
|
if (role && !role.isImplicit) {
|
|
170
165
|
results.push(true);
|
|
@@ -198,8 +193,7 @@ el) {
|
|
|
198
193
|
function isExposedElement(
|
|
199
194
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
200
195
|
el, specs) {
|
|
201
|
-
|
|
202
|
-
const svgRenderedConditions = (_a = specs.def['#contentModels']['#SVGRenderable']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
196
|
+
const svgRenderedConditions = specs.def['#contentModels']['#SVGRenderable']?.join(',');
|
|
203
197
|
if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
|
|
204
198
|
return true;
|
|
205
199
|
}
|
|
@@ -208,8 +202,7 @@ el, specs) {
|
|
|
208
202
|
function isNotMetaOrHiddenHTMLElement(
|
|
209
203
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
210
204
|
el, specs) {
|
|
211
|
-
|
|
212
|
-
const metadataConditions = (_a = specs.def['#contentModels']['#metadata']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
205
|
+
const metadataConditions = specs.def['#contentModels']['#metadata']?.join(',');
|
|
213
206
|
if (metadataConditions && el.matches(metadataConditions)) {
|
|
214
207
|
return false;
|
|
215
208
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function matchesContextRole(conditions: readonly string[], ownedEl: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.matchesContextRole = void 0;
|
|
4
|
-
const get_computed_role_1 = require("./get-computed-role");
|
|
5
|
-
function matchesContextRole(conditions,
|
|
1
|
+
import { getComputedRole } from './get-computed-role.js';
|
|
2
|
+
export function matchesContextRole(conditions,
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
ownedEl, specs, version) {
|
|
8
5
|
return conditions.some(condition => matchesCondition(condition, ownedEl.parentElement, specs, version));
|
|
9
6
|
}
|
|
10
|
-
exports.matchesContextRole = matchesContextRole;
|
|
11
7
|
function matchesCondition(condition,
|
|
12
8
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
13
9
|
parentEl, specs, version) {
|
|
@@ -17,8 +13,8 @@ parentEl, specs, version) {
|
|
|
17
13
|
return false;
|
|
18
14
|
}
|
|
19
15
|
const condition = conditions.shift();
|
|
20
|
-
const parentRole =
|
|
21
|
-
if (condition !==
|
|
16
|
+
const parentRole = getComputedRole(specs, parentEl, version, true).role;
|
|
17
|
+
if (condition !== parentRole?.name) {
|
|
22
18
|
return false;
|
|
23
19
|
}
|
|
24
20
|
parentEl = parentEl.parentElement;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.mayBeFocusable = void 0;
|
|
4
|
-
const get_selectors_by_content_model_category_1 = require("../specs/get-selectors-by-content-model-category");
|
|
5
|
-
function mayBeFocusable(
|
|
1
|
+
import { getSelectorsByContentModelCategory } from '../specs/get-selectors-by-content-model-category.js';
|
|
2
|
+
export function mayBeFocusable(
|
|
6
3
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
4
|
el, specs) {
|
|
8
5
|
return [
|
|
@@ -11,7 +8,7 @@ el, specs) {
|
|
|
11
8
|
*
|
|
12
9
|
* @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
|
|
13
10
|
*/
|
|
14
|
-
...
|
|
11
|
+
...getSelectorsByContentModelCategory(specs, '#interactive'),
|
|
15
12
|
/**
|
|
16
13
|
* Interaction
|
|
17
14
|
*
|
|
@@ -21,4 +18,3 @@ el, specs) {
|
|
|
21
18
|
'[contenteditable]:not([contenteditable="false" i])',
|
|
22
19
|
].some(selector => el.matches(selector));
|
|
23
20
|
}
|
|
24
|
-
exports.mayBeFocusable = mayBeFocusable;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export { getAttrSpecs as getAttrSpecsByNames } from './specs/get-attr-specs';
|
|
2
|
-
export * from './constant/aria-version';
|
|
3
|
-
export * from './dom-traverse/accname-computation';
|
|
4
|
-
export * from './dom-traverse/get-attr-specs';
|
|
5
|
-
export * from './dom-traverse/get-computed-aria-props';
|
|
6
|
-
export * from './dom-traverse/get-computed-role';
|
|
7
|
-
export * from './dom-traverse/get-content-model';
|
|
8
|
-
export * from './dom-traverse/get-implicit-role';
|
|
9
|
-
export * from './dom-traverse/get-permitted-roles';
|
|
10
|
-
export * from './dom-traverse/get-spec';
|
|
11
|
-
export * from './dom-traverse/has-required-owned-elements';
|
|
12
|
-
export * from './dom-traverse/is-exposed';
|
|
13
|
-
export * from './dom-traverse/may-be-focusable';
|
|
14
|
-
export * from './specs/aria-specs';
|
|
15
|
-
export * from './specs/content-model-category-to-tag-names';
|
|
16
|
-
export * from './specs/get-aria';
|
|
17
|
-
export * from './specs/get-role-spec';
|
|
18
|
-
export * from './specs/get-spec-by-tag-name';
|
|
19
|
-
export * from './specs/is-nothing-content-model';
|
|
20
|
-
export * from './specs/is-palpable-elements';
|
|
21
|
-
export * from './specs/is-void-element';
|
|
22
|
-
export * from './specs/schema-to-spec';
|
|
23
|
-
export * from './types';
|
|
24
|
-
export * from './types/aria';
|
|
25
|
-
export * from './types/attributes';
|
|
26
|
-
export * from './types/permitted-structures';
|
|
27
|
-
export * from './utils/resolve-namespace';
|
|
28
|
-
export * from './utils/validateAriaVersion';
|
|
1
|
+
export { getAttrSpecs as getAttrSpecsByNames } from './specs/get-attr-specs.js';
|
|
2
|
+
export * from './constant/aria-version.js';
|
|
3
|
+
export * from './dom-traverse/accname-computation.js';
|
|
4
|
+
export * from './dom-traverse/get-attr-specs.js';
|
|
5
|
+
export * from './dom-traverse/get-computed-aria-props.js';
|
|
6
|
+
export * from './dom-traverse/get-computed-role.js';
|
|
7
|
+
export * from './dom-traverse/get-content-model.js';
|
|
8
|
+
export * from './dom-traverse/get-implicit-role.js';
|
|
9
|
+
export * from './dom-traverse/get-permitted-roles.js';
|
|
10
|
+
export * from './dom-traverse/get-spec.js';
|
|
11
|
+
export * from './dom-traverse/has-required-owned-elements.js';
|
|
12
|
+
export * from './dom-traverse/is-exposed.js';
|
|
13
|
+
export * from './dom-traverse/may-be-focusable.js';
|
|
14
|
+
export * from './specs/aria-specs.js';
|
|
15
|
+
export * from './specs/content-model-category-to-tag-names.js';
|
|
16
|
+
export * from './specs/get-aria.js';
|
|
17
|
+
export * from './specs/get-role-spec.js';
|
|
18
|
+
export * from './specs/get-spec-by-tag-name.js';
|
|
19
|
+
export * from './specs/is-nothing-content-model.js';
|
|
20
|
+
export * from './specs/is-palpable-elements.js';
|
|
21
|
+
export * from './specs/is-void-element.js';
|
|
22
|
+
export * from './specs/schema-to-spec.js';
|
|
23
|
+
export * from './types/index.js';
|
|
24
|
+
export * from './types/aria.js';
|
|
25
|
+
export * from './types/attributes.js';
|
|
26
|
+
export * from './types/permitted-structures.js';
|
|
27
|
+
export * from './utils/resolve-namespace.js';
|
|
28
|
+
export * from './utils/validateAriaVersion.js';
|
package/lib/index.js
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
tslib_1.__exportStar(require("./types/aria"), exports);
|
|
30
|
-
tslib_1.__exportStar(require("./types/attributes"), exports);
|
|
31
|
-
tslib_1.__exportStar(require("./types/permitted-structures"), exports);
|
|
32
|
-
tslib_1.__exportStar(require("./utils/resolve-namespace"), exports);
|
|
33
|
-
tslib_1.__exportStar(require("./utils/validateAriaVersion"), exports);
|
|
1
|
+
export { getAttrSpecs as getAttrSpecsByNames } from './specs/get-attr-specs.js';
|
|
2
|
+
export * from './constant/aria-version.js';
|
|
3
|
+
export * from './dom-traverse/accname-computation.js';
|
|
4
|
+
export * from './dom-traverse/get-attr-specs.js';
|
|
5
|
+
export * from './dom-traverse/get-computed-aria-props.js';
|
|
6
|
+
export * from './dom-traverse/get-computed-role.js';
|
|
7
|
+
export * from './dom-traverse/get-content-model.js';
|
|
8
|
+
export * from './dom-traverse/get-implicit-role.js';
|
|
9
|
+
export * from './dom-traverse/get-permitted-roles.js';
|
|
10
|
+
export * from './dom-traverse/get-spec.js';
|
|
11
|
+
export * from './dom-traverse/has-required-owned-elements.js';
|
|
12
|
+
export * from './dom-traverse/is-exposed.js';
|
|
13
|
+
export * from './dom-traverse/may-be-focusable.js';
|
|
14
|
+
export * from './specs/aria-specs.js';
|
|
15
|
+
export * from './specs/content-model-category-to-tag-names.js';
|
|
16
|
+
export * from './specs/get-aria.js';
|
|
17
|
+
export * from './specs/get-role-spec.js';
|
|
18
|
+
export * from './specs/get-spec-by-tag-name.js';
|
|
19
|
+
export * from './specs/is-nothing-content-model.js';
|
|
20
|
+
export * from './specs/is-palpable-elements.js';
|
|
21
|
+
export * from './specs/is-void-element.js';
|
|
22
|
+
export * from './specs/schema-to-spec.js';
|
|
23
|
+
export * from './types/index.js';
|
|
24
|
+
export * from './types/aria.js';
|
|
25
|
+
export * from './types/attributes.js';
|
|
26
|
+
export * from './types/permitted-structures.js';
|
|
27
|
+
export * from './utils/resolve-namespace.js';
|
|
28
|
+
export * from './utils/validateAriaVersion.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types/index.js';
|
|
2
2
|
export declare function ariaSpecs(specs: MLMLSpec, version: ARIAVersion): {
|
|
3
|
-
readonly roles: readonly import("../types").ARIARoleInSchema[];
|
|
4
|
-
readonly graphicsRoles: readonly import("../types").ARIARoleInSchema[];
|
|
5
|
-
readonly props: readonly import("../types").ARIAProperty[];
|
|
3
|
+
readonly roles: readonly import("../types/index.js").ARIARoleInSchema[];
|
|
4
|
+
readonly graphicsRoles: readonly import("../types/index.js").ARIARoleInSchema[];
|
|
5
|
+
readonly props: readonly import("../types/index.js").ARIAProperty[];
|
|
6
6
|
};
|
package/lib/specs/aria-specs.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ariaSpecs = void 0;
|
|
4
|
-
function ariaSpecs(specs, version) {
|
|
1
|
+
export function ariaSpecs(specs, version) {
|
|
5
2
|
const aria = specs.def['#aria'];
|
|
6
3
|
return aria[version];
|
|
7
4
|
}
|
|
8
|
-
exports.ariaSpecs = ariaSpecs;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
2
|
-
import type { Category } from '../types/permitted-structures';
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
import type { Category } from '../types/permitted-structures.js';
|
|
3
3
|
export declare function contentModelCategoryToTagNames(contentModel: Category, def: MLMLSpec['def']): ReadonlyArray<string>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contentModelCategoryToTagNames = void 0;
|
|
4
1
|
const cache = new Map();
|
|
5
|
-
function contentModelCategoryToTagNames(contentModel, def) {
|
|
2
|
+
export function contentModelCategoryToTagNames(contentModel, def) {
|
|
6
3
|
const cached = cache.get(contentModel);
|
|
7
4
|
if (cached) {
|
|
8
5
|
return cached;
|
|
@@ -12,4 +9,3 @@ function contentModelCategoryToTagNames(contentModel, def) {
|
|
|
12
9
|
cache.set(contentModel, sortedTag);
|
|
13
10
|
return sortedTag;
|
|
14
11
|
}
|
|
15
|
-
exports.contentModelCategoryToTagNames = contentModelCategoryToTagNames;
|
package/lib/specs/get-aria.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ARIA } from '../types/aria.js';
|
|
2
|
+
import type { ARIAVersion, Matches, MLMLSpec } from '../types/index.js';
|
|
3
3
|
import type { ReadonlyDeep } from 'type-fest';
|
|
4
4
|
export declare function getARIA(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): Omit<ReadonlyDeep<ARIA>, ARIAVersion | 'conditions'> | null;
|
package/lib/specs/get-aria.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getARIA = void 0;
|
|
4
|
-
const get_spec_by_tag_name_1 = require("./get-spec-by-tag-name");
|
|
5
|
-
const resolve_version_1 = require("./resolve-version");
|
|
1
|
+
import { getSpecByTagName } from './get-spec-by-tag-name.js';
|
|
2
|
+
import { resolveVersion } from './resolve-version.js';
|
|
6
3
|
const cache = new Map();
|
|
7
|
-
function getARIA(specs, localName, namespace, version, matches) {
|
|
8
|
-
var _a, _b, _c, _d, _e;
|
|
4
|
+
export function getARIA(specs, localName, namespace, version, matches) {
|
|
9
5
|
const aria = getVersionResolvedARIA(specs, localName, namespace, version);
|
|
10
6
|
if (!aria) {
|
|
11
7
|
return null;
|
|
@@ -24,11 +20,11 @@ function getARIA(specs, localName, namespace, version, matches) {
|
|
|
24
20
|
if (!condARIA) {
|
|
25
21
|
continue;
|
|
26
22
|
}
|
|
27
|
-
implicitRole =
|
|
28
|
-
permittedRoles =
|
|
29
|
-
implicitProperties =
|
|
30
|
-
properties =
|
|
31
|
-
namingProhibited =
|
|
23
|
+
implicitRole = condARIA.implicitRole ?? implicitRole;
|
|
24
|
+
permittedRoles = condARIA.permittedRoles ?? permittedRoles;
|
|
25
|
+
implicitProperties = condARIA.implicitProperties ?? implicitProperties;
|
|
26
|
+
properties = condARIA.properties ?? properties;
|
|
27
|
+
namingProhibited = condARIA.namingProhibited ?? namingProhibited;
|
|
32
28
|
}
|
|
33
29
|
return {
|
|
34
30
|
implicitRole,
|
|
@@ -38,20 +34,18 @@ function getARIA(specs, localName, namespace, version, matches) {
|
|
|
38
34
|
namingProhibited,
|
|
39
35
|
};
|
|
40
36
|
}
|
|
41
|
-
exports.getARIA = getARIA;
|
|
42
37
|
function getVersionResolvedARIA(specs, localName, namespace, version) {
|
|
43
|
-
var _a;
|
|
44
38
|
const key = localName + namespace + version;
|
|
45
39
|
let aria = cache.get(key);
|
|
46
40
|
if (aria !== undefined) {
|
|
47
41
|
return aria;
|
|
48
42
|
}
|
|
49
|
-
const spec =
|
|
43
|
+
const spec = getSpecByTagName(specs.specs, localName, namespace)?.aria;
|
|
50
44
|
if (!spec) {
|
|
51
45
|
cache.set(key, null);
|
|
52
46
|
return null;
|
|
53
47
|
}
|
|
54
|
-
aria =
|
|
48
|
+
aria = resolveVersion(spec, version);
|
|
55
49
|
if (aria.permittedRoles !== false) {
|
|
56
50
|
aria = {
|
|
57
51
|
...aria,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MLMLSpec, Attribute } from '../types';
|
|
1
|
+
import type { MLMLSpec, Attribute } from '../types/index.js';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
3
|
export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): readonly Attribute[] | null;
|
|
4
4
|
type HasName = {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nameCompare = exports.getAttrSpecs = void 0;
|
|
4
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
1
|
+
import { resolveNamespace } from '../utils/resolve-namespace.js';
|
|
5
2
|
const cacheMap = new Map();
|
|
6
3
|
const schemaCache = new WeakSet();
|
|
7
|
-
function getAttrSpecs(localName, namespace, schema) {
|
|
4
|
+
export function getAttrSpecs(localName, namespace, schema) {
|
|
8
5
|
if (!schemaCache.has(schema)) {
|
|
9
6
|
cacheMap.clear();
|
|
10
7
|
}
|
|
11
|
-
const { localNameWithNS } =
|
|
8
|
+
const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined);
|
|
12
9
|
const cache = cacheMap.get(localNameWithNS);
|
|
13
10
|
if (cache !== undefined) {
|
|
14
11
|
return cache;
|
|
@@ -70,8 +67,7 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
70
67
|
cacheMap.set(localNameWithNS, attrList);
|
|
71
68
|
return attrList;
|
|
72
69
|
}
|
|
73
|
-
|
|
74
|
-
function nameCompare(a, b) {
|
|
70
|
+
export function nameCompare(a, b) {
|
|
75
71
|
const nameA = typeof a === 'string' ? a : a.name.toUpperCase();
|
|
76
72
|
const nameB = typeof b === 'string' ? b : b.name.toUpperCase();
|
|
77
73
|
if (nameA < nameB) {
|
|
@@ -82,4 +78,3 @@ function nameCompare(a, b) {
|
|
|
82
78
|
}
|
|
83
79
|
return 0;
|
|
84
80
|
}
|
|
85
|
-
exports.nameCompare = nameCompare;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): import("
|
|
1
|
+
import type { ARIAVersion, Matches, MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function getImplicitRole(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): import("../index.js").ImplicitRole;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const get_aria_1 = require("./get-aria");
|
|
5
|
-
function getImplicitRole(specs, localName, namespace, version, matches) {
|
|
6
|
-
const aria = (0, get_aria_1.getARIA)(specs, localName, namespace, version, matches);
|
|
1
|
+
import { getARIA } from './get-aria.js';
|
|
2
|
+
export function getImplicitRole(specs, localName, namespace, version, matches) {
|
|
3
|
+
const aria = getARIA(specs, localName, namespace, version, matches);
|
|
7
4
|
if (!aria) {
|
|
8
5
|
return false;
|
|
9
6
|
}
|
|
10
7
|
return aria.implicitRole;
|
|
11
8
|
}
|
|
12
|
-
exports.getImplicitRole = getImplicitRole;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const aria_specs_1 = require("./aria-specs");
|
|
7
|
-
const get_aria_1 = require("./get-aria");
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { isPlainObject } from 'is-plain-object';
|
|
3
|
+
import { mergeArray } from '../utils/merge-array.js';
|
|
4
|
+
import { ariaSpecs } from './aria-specs.js';
|
|
5
|
+
import { getARIA } from './get-aria.js';
|
|
8
6
|
/**
|
|
9
7
|
* Getting permitted ARIA roles.
|
|
10
8
|
*
|
|
@@ -12,16 +10,16 @@ const get_aria_1 = require("./get-aria");
|
|
|
12
10
|
* - If `true`, this mean is "Any".
|
|
13
11
|
* - If `false`, this mean is "No".
|
|
14
12
|
*/
|
|
15
|
-
function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
16
|
-
const aria =
|
|
13
|
+
export function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
14
|
+
const aria = getARIA(specs, localName, namespace, version, matches);
|
|
17
15
|
if (!aria) {
|
|
18
16
|
return [];
|
|
19
17
|
}
|
|
20
18
|
const { implicitRole, permittedRoles } = aria;
|
|
21
|
-
const { roles, graphicsRoles } =
|
|
19
|
+
const { roles, graphicsRoles } = ariaSpecs(specs, version);
|
|
22
20
|
let permittedRoleList = [];
|
|
23
21
|
if (permittedRoles === true) {
|
|
24
|
-
permittedRoleList =
|
|
22
|
+
permittedRoleList = mergeArray(permittedRoleList, roles
|
|
25
23
|
.filter(role => !role.isAbstract)
|
|
26
24
|
.map(role => ({
|
|
27
25
|
name: role.name,
|
|
@@ -29,14 +27,14 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
29
27
|
}
|
|
30
28
|
if (isAAMInfo(permittedRoles)) {
|
|
31
29
|
if (permittedRoles['core-aam']) {
|
|
32
|
-
permittedRoleList =
|
|
30
|
+
permittedRoleList = mergeArray(permittedRoleList, roles
|
|
33
31
|
.filter(role => !role.isAbstract)
|
|
34
32
|
.map(role => ({
|
|
35
33
|
name: role.name,
|
|
36
34
|
})));
|
|
37
35
|
}
|
|
38
36
|
if (permittedRoles['graphics-aam']) {
|
|
39
|
-
permittedRoleList =
|
|
37
|
+
permittedRoleList = mergeArray(permittedRoleList, graphicsRoles
|
|
40
38
|
.filter(role => !role.isAbstract)
|
|
41
39
|
.map(role => ({
|
|
42
40
|
name: role.name,
|
|
@@ -44,7 +42,7 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
else if (typeof permittedRoles !== 'boolean') {
|
|
47
|
-
permittedRoleList =
|
|
45
|
+
permittedRoleList = mergeArray(permittedRoleList, permittedRoles.map(role => {
|
|
48
46
|
if (typeof role === 'string') {
|
|
49
47
|
return {
|
|
50
48
|
name: role,
|
|
@@ -57,9 +55,8 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
57
55
|
return permittedRoleList;
|
|
58
56
|
}
|
|
59
57
|
const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
|
|
60
|
-
return
|
|
58
|
+
return mergeArray(implicitRoles.map(r => ({ name: r })), permittedRoleList);
|
|
61
59
|
}
|
|
62
|
-
exports.getPermittedRoles = getPermittedRoles;
|
|
63
60
|
function isAAMInfo(permittedRoles) {
|
|
64
|
-
return
|
|
61
|
+
return isPlainObject(permittedRoles);
|
|
65
62
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types';
|
|
1
|
+
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types/index.js';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
3
|
export declare function getRoleSpec(specs: MLMLSpec, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
|
|
4
4
|
superClassRoles: ARIARoleInSchema[];
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getRoleSpec = void 0;
|
|
4
|
-
const aria_specs_1 = require("./aria-specs");
|
|
5
|
-
function getRoleSpec(specs, roleName, namespace, version) {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
1
|
+
import { ariaSpecs } from './aria-specs.js';
|
|
2
|
+
export function getRoleSpec(specs, roleName, namespace, version) {
|
|
7
3
|
const role = getRoleByName(specs, roleName, namespace, version);
|
|
8
4
|
if (!role) {
|
|
9
5
|
return null;
|
|
@@ -12,19 +8,18 @@ function getRoleSpec(specs, roleName, namespace, version) {
|
|
|
12
8
|
return {
|
|
13
9
|
name: role.name,
|
|
14
10
|
isAbstract: !!role.isAbstract,
|
|
15
|
-
requiredContextRole:
|
|
16
|
-
requiredOwnedElements:
|
|
11
|
+
requiredContextRole: role.requiredContextRole ?? [],
|
|
12
|
+
requiredOwnedElements: role.requiredOwnedElements ?? [],
|
|
17
13
|
accessibleNameRequired: !!role.accessibleNameRequired,
|
|
18
14
|
accessibleNameFromAuthor: !!role.accessibleNameFromAuthor,
|
|
19
15
|
accessibleNameFromContent: !!role.accessibleNameFromContent,
|
|
20
16
|
accessibleNameProhibited: !!role.accessibleNameProhibited,
|
|
21
17
|
childrenPresentational: !!role.childrenPresentational,
|
|
22
|
-
ownedProperties:
|
|
23
|
-
prohibitedProperties:
|
|
18
|
+
ownedProperties: role.ownedProperties ?? [],
|
|
19
|
+
prohibitedProperties: role.prohibitedProperties ?? [],
|
|
24
20
|
superClassRoles,
|
|
25
21
|
};
|
|
26
22
|
}
|
|
27
|
-
exports.getRoleSpec = getRoleSpec;
|
|
28
23
|
function recursiveTraverseSuperClassRoles(specs, roleName, namespace, version) {
|
|
29
24
|
const roles = [];
|
|
30
25
|
const superClassRoles = getSuperClassRoles(specs, roleName, namespace, version);
|
|
@@ -38,12 +33,13 @@ function recursiveTraverseSuperClassRoles(specs, roleName, namespace, version) {
|
|
|
38
33
|
return roles;
|
|
39
34
|
}
|
|
40
35
|
function getSuperClassRoles(specs, roleName, namespace, version) {
|
|
41
|
-
var _a, _b;
|
|
42
36
|
const role = getRoleByName(specs, roleName, namespace, version);
|
|
43
|
-
return (
|
|
37
|
+
return (role?.generalization
|
|
38
|
+
?.map(roleName => getRoleByName(specs, roleName, namespace, version))
|
|
39
|
+
.filter((role) => !!role) ?? null);
|
|
44
40
|
}
|
|
45
41
|
function getRoleByName(specs, roleName, namespace, version) {
|
|
46
|
-
const { roles, graphicsRoles } =
|
|
42
|
+
const { roles, graphicsRoles } = ariaSpecs(specs, version);
|
|
47
43
|
let role = roles.find(r => r.name === roleName);
|
|
48
44
|
if (!role && namespace === 'http://www.w3.org/2000/svg') {
|
|
49
45
|
role = graphicsRoles.find(r => r.name === roleName);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
2
|
-
import type { Category } from '../types/permitted-structures';
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
import type { Category } from '../types/permitted-structures.js';
|
|
3
3
|
export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSelectorsByContentModelCategory = void 0;
|
|
4
|
-
function getSelectorsByContentModelCategory(specs, category) {
|
|
1
|
+
export function getSelectorsByContentModelCategory(specs, category) {
|
|
5
2
|
const selectors = specs.def['#contentModels'][category];
|
|
6
|
-
return selectors
|
|
3
|
+
return selectors ?? [];
|
|
7
4
|
}
|
|
8
|
-
exports.getSelectorsByContentModelCategory = getSelectorsByContentModelCategory;
|