@markuplint/ml-spec 3.0.0-alpha.82 → 3.0.0-dev.176
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/README.md +8 -3
- package/lib/constant/aria-version.d.ts +2 -0
- package/lib/constant/aria-version.js +5 -0
- package/lib/dom-traverse/accname-computation.js +3 -1
- package/lib/dom-traverse/get-attr-specs.d.ts +1 -1
- package/lib/dom-traverse/get-attr-specs.js +3 -1
- package/lib/dom-traverse/get-computed-aria-props.d.ts +12 -0
- package/lib/dom-traverse/get-computed-aria-props.js +108 -0
- package/lib/dom-traverse/get-computed-role.d.ts +6 -1
- package/lib/dom-traverse/get-computed-role.js +54 -35
- package/lib/dom-traverse/get-content-model.d.ts +29 -0
- package/lib/dom-traverse/get-content-model.js +30 -0
- package/lib/dom-traverse/get-explicit-role.js +9 -4
- package/lib/dom-traverse/get-implicit-role.d.ts +6 -2
- package/lib/dom-traverse/get-implicit-role.js +6 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +10 -4
- package/lib/dom-traverse/get-non-presentational-ancestor.js +10 -2
- package/lib/dom-traverse/get-permitted-roles.d.ts +7 -3
- package/lib/dom-traverse/get-permitted-roles.js +3 -1
- package/lib/dom-traverse/get-spec.d.ts +5 -2
- package/lib/dom-traverse/get-spec.js +4 -2
- package/lib/dom-traverse/has-required-owned-elements.d.ts +8 -2
- package/lib/dom-traverse/has-required-owned-elements.js +26 -8
- package/lib/dom-traverse/is-exposed.d.ts +11 -0
- package/lib/dom-traverse/is-exposed.js +217 -0
- package/lib/dom-traverse/matches-context-role.d.ts +7 -0
- package/lib/dom-traverse/matches-context-role.js +27 -0
- package/lib/dom-traverse/may-be-focusable.d.ts +2 -0
- package/lib/dom-traverse/may-be-focusable.js +24 -0
- package/lib/index.d.ts +11 -1
- package/lib/index.js +11 -1
- package/lib/specs/aria-specs.d.ts +7 -4
- package/lib/specs/content-model-category-to-tag-names.d.ts +5 -2
- package/lib/specs/content-model-category-to-tag-names.js +2 -2
- package/lib/specs/get-aria.d.ts +8 -1
- package/lib/specs/get-aria.js +11 -5
- package/lib/specs/get-attr-specs.d.ts +7 -3
- package/lib/specs/get-attr-specs.js +2 -14
- package/lib/specs/get-implicit-role.d.ts +7 -1
- package/lib/specs/get-permitted-roles.d.ts +9 -3
- package/lib/specs/get-permitted-roles.js +19 -15
- package/lib/specs/get-role-spec.d.ts +10 -3
- package/lib/specs/get-role-spec.js +2 -2
- package/lib/specs/get-selectors-by-content-model-category.d.ts +2 -2
- package/lib/specs/get-selectors-by-content-model-category.js +1 -1
- package/lib/specs/get-spec-by-tag-name.d.ts +6 -2
- package/lib/specs/get-spec-by-tag-name.js +3 -2
- package/lib/specs/is-nothing-content-model.d.ts +5 -0
- package/lib/specs/is-nothing-content-model.js +14 -0
- package/lib/specs/is-palpable-elements.d.ts +9 -0
- package/lib/specs/is-palpable-elements.js +49 -0
- package/lib/specs/is-void-element.d.ts +1 -0
- package/lib/specs/is-void-element.js +27 -0
- package/lib/specs/resolve-version.d.ts +5 -1
- package/lib/specs/resolve-version.js +1 -1
- package/lib/specs/schema-to-spec.d.ts +4 -4
- package/lib/specs/schema-to-spec.js +29 -18
- package/lib/types/aria.d.ts +150 -109
- package/lib/types/attributes.d.ts +1507 -73
- package/lib/types/index.d.ts +195 -166
- package/{src/types/permitted-structres.ts → lib/types/permitted-structures.d.ts} +24 -35
- package/lib/utils/get-ns.d.ts +2 -1
- package/lib/utils/get-ns.js +3 -0
- package/lib/utils/merge-array.d.ts +9 -4
- package/lib/utils/resolve-namespace.d.ts +7 -7
- package/lib/utils/resolve-namespace.js +19 -13
- package/lib/utils/validateAriaVersion.d.ts +2 -0
- package/lib/utils/validateAriaVersion.js +8 -0
- package/package.json +13 -8
- package/schema.json +6 -6
- package/{src/dom-traverse/accname-computation.spec.ts → test/dom-traverse/accname-computation.spec.js} +8 -8
- package/test/dom-traverse/get-computed-aria-props.spec.js +758 -0
- package/test/dom-traverse/get-computed-role.spec.js +294 -0
- package/test/dom-traverse/get-implicit-role.spec.js +40 -0
- package/{src/dom-traverse/has-required-owned-elements.spec.ts → test/dom-traverse/has-required-owned-elements.spec.js} +7 -9
- package/test/dom-traverse/is-exposed.spec.js +70 -0
- package/test/dom-traverse/matches-context-role.spec.js +60 -0
- package/{src/specs/get-attr-specs.spec.ts → test/specs/get-attr-specs.spec.js} +2 -8
- package/{src/specs/get-implicit-role.spec.ts → test/specs/get-implicit-role.spec.js} +9 -11
- package/{src/specs/get-permitted-roles.spec.ts → test/specs/get-permitted-roles.spec.js} +8 -10
- package/{src/specs/get-role-spec.spec.ts → test/specs/get-role-spec.spec.js} +4 -4
- package/{src/specs/get-spec-by-tag-name.spec.ts → test/specs/get-spec-by-tag-name.spec.js} +11 -11
- package/test/specs/resolve-version.spec.js +34 -0
- package/test/specs/schema-to-spec.spec.js +61 -0
- package/test/utils/resolve-namespace.spec.js +37 -0
- package/lib/dom-traverse/focusability-computation.d.ts +0 -1
- package/lib/dom-traverse/focusability-computation.js +0 -8
- package/lib/dom-traverse/get-aria.d.ts +0 -9
- package/lib/dom-traverse/get-aria.js +0 -54
- package/lib/specs/aria-spec.d.ts +0 -5
- package/lib/specs/aria-spec.js +0 -12
- package/lib/specs/get-spec.d.ts +0 -13
- package/lib/specs/get-spec.js +0 -85
- package/lib/specs/html-spec.d.ts +0 -6
- package/lib/specs/html-spec.js +0 -16
- package/lib/specs/resolve-namespace.d.ts +0 -9
- package/lib/specs/resolve-namespace.js +0 -26
- package/lib/types/permitted-structres.d.ts +0 -64
- package/lib/utils.d.ts +0 -8
- package/lib/utils.js +0 -50
- package/schemas/aria.schema.json +0 -258
- package/schemas/attributes.schema.json +0 -204
- package/schemas/content-models.schema.json +0 -215
- package/schemas/element.schema.json +0 -11
- package/schemas/global-attributes.schema.json +0 -761
- 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-role.spec.ts +0 -134
- package/src/dom-traverse/get-computed-role.ts +0 -193
- 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.ts +0 -72
- package/src/index.ts +0 -17
- 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.ts +0 -116
- package/src/specs/get-implicit-role.ts +0 -17
- package/src/specs/get-permitted-roles.ts +0 -87
- 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.ts +0 -16
- package/src/specs/is-presentational.ts +0 -6
- 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 -147
- package/src/types/attributes.ts +0 -1418
- package/src/types/index.ts +0 -255
- package/src/utils/get-ns.ts +0 -13
- package/src/utils/merge-array.ts +0 -35
- package/src/utils/resolve-namespace.ts +0 -36
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
- /package/lib/types/{permitted-structres.js → permitted-structures.js} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Detect including/excluding from the Accessibility Tree
|
|
4
|
+
*
|
|
5
|
+
* @see https://www.w3.org/TR/wai-aria-1.2/#accessibility_tree
|
|
6
|
+
*
|
|
7
|
+
* @param specs
|
|
8
|
+
* @param el
|
|
9
|
+
* @param version
|
|
10
|
+
*/
|
|
11
|
+
export declare function isExposed(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isExposed = void 0;
|
|
4
|
+
const aria_specs_1 = require("../specs/aria-specs");
|
|
5
|
+
const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
|
|
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");
|
|
9
|
+
/**
|
|
10
|
+
* Detect including/excluding from the Accessibility Tree
|
|
11
|
+
*
|
|
12
|
+
* @see https://www.w3.org/TR/wai-aria-1.2/#accessibility_tree
|
|
13
|
+
*
|
|
14
|
+
* @param specs
|
|
15
|
+
* @param el
|
|
16
|
+
* @param version
|
|
17
|
+
*/
|
|
18
|
+
function isExposed(
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
20
|
+
el, specs, version) {
|
|
21
|
+
// According to WAI-ARIA
|
|
22
|
+
if (isExcluding(el, specs, version)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
// Return true if the element is unknown, deprecated, or obsolete.
|
|
26
|
+
const { localName, namespace } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
|
|
27
|
+
const spec = (0, get_spec_by_tag_name_1.getSpecByTagName)(specs.specs, localName, namespace);
|
|
28
|
+
if (!spec || spec.deprecated || spec.obsolete != null) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
// According to HTML and SVG Specs with **the author's interpretation**
|
|
32
|
+
{
|
|
33
|
+
if (!isExposedElement(el, specs)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// According to WAI-ARIA
|
|
38
|
+
{
|
|
39
|
+
const exposable = isIncluding(el, specs, version);
|
|
40
|
+
if (exposable) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Default
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
exports.isExposed = isExposed;
|
|
48
|
+
/**
|
|
49
|
+
* Excluding Elements from the Accessibility Tree
|
|
50
|
+
*
|
|
51
|
+
* @see https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
|
|
52
|
+
*
|
|
53
|
+
* @param specs
|
|
54
|
+
* @param el
|
|
55
|
+
* @param version
|
|
56
|
+
*/
|
|
57
|
+
function isExcluding(
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
59
|
+
el, specs, version) {
|
|
60
|
+
var _a;
|
|
61
|
+
/**
|
|
62
|
+
* The following elements are not exposed via the accessibility API and
|
|
63
|
+
* user agents MUST NOT include them in the accessibility tree:
|
|
64
|
+
* - Elements, including their descendent elements,
|
|
65
|
+
* that have host language semantics specifying
|
|
66
|
+
* that the element is not displayed, such as CSS display:none,
|
|
67
|
+
* visibility:hidden, or the HTML hidden attribute.
|
|
68
|
+
*/
|
|
69
|
+
{
|
|
70
|
+
let currentEl = el;
|
|
71
|
+
while (currentEl) {
|
|
72
|
+
if (hasDisplayNodeOrVisibilityHidden(currentEl) || currentEl.hasAttribute('hidden')) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
currentEl = currentEl.parentElement;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* - Elements with none or presentation as the first role in the role attribute.
|
|
80
|
+
* However, their exclusion is conditional. In addition,
|
|
81
|
+
* the element's descendants and text content are generally included.
|
|
82
|
+
* These exceptions and conditions are documented in the presentation (role)
|
|
83
|
+
* section.
|
|
84
|
+
*/
|
|
85
|
+
if ((0, is_presentational_1.isPresentational)(((_a = el.getAttribute('role')) !== null && _a !== void 0 ? _a : '').split(/\s+/)[0])) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* If not already excluded from the accessibility tree per the above rules,
|
|
90
|
+
* user agents SHOULD NOT include the following elements
|
|
91
|
+
* in the accessibility tree:
|
|
92
|
+
* - Elements, including their descendants, that have aria-hidden set to true.
|
|
93
|
+
* In other words, aria-hidden="true" on a parent overrides aria-hidden="false"
|
|
94
|
+
* on descendants.
|
|
95
|
+
*/
|
|
96
|
+
{
|
|
97
|
+
let currentEl = el;
|
|
98
|
+
while (currentEl) {
|
|
99
|
+
if (currentEl.getAttribute('aria-hidden') === 'true') {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
currentEl = currentEl.parentElement;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* - Any descendants of elements that have the characteristic
|
|
107
|
+
* "Children Presentational: True" unless the descendant
|
|
108
|
+
* is not allowed to be presentational because it meets one of
|
|
109
|
+
* the conditions for exception described in
|
|
110
|
+
* Presentational Roles Conflict Resolution.
|
|
111
|
+
* However, the text content of any excluded descendants is included.
|
|
112
|
+
*/
|
|
113
|
+
{
|
|
114
|
+
let currentEl = el.parentElement;
|
|
115
|
+
while (currentEl) {
|
|
116
|
+
const { role } = (0, get_computed_role_1.getComputedRole)(specs, currentEl, version);
|
|
117
|
+
if (role === null || role === void 0 ? void 0 : role.childrenPresentational) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
currentEl = currentEl.parentElement;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Including Elements in the Accessibility Tree
|
|
127
|
+
*
|
|
128
|
+
* If not excluded from or marked as hidden in the accessibility tree
|
|
129
|
+
* per the rules above in Excluding Elements in the Accessibility Tree,
|
|
130
|
+
* user agents MUST provide an accessible object in the accessibility tree
|
|
131
|
+
* for DOM elements that meet any of the following criteria:
|
|
132
|
+
*
|
|
133
|
+
* @see https://www.w3.org/TR/wai-aria-1.2/#tree_inclusion
|
|
134
|
+
*
|
|
135
|
+
* @param specs
|
|
136
|
+
* @param el
|
|
137
|
+
* @param version
|
|
138
|
+
*/
|
|
139
|
+
function isIncluding(
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
141
|
+
el, specs, version) {
|
|
142
|
+
/**
|
|
143
|
+
* > **meet any** of the following criteria:
|
|
144
|
+
*/
|
|
145
|
+
const results = [];
|
|
146
|
+
/**
|
|
147
|
+
* Elements that are not hidden and may fire an accessibility API event,
|
|
148
|
+
* including:
|
|
149
|
+
* - Elements that are currently focused, even if the element or one of
|
|
150
|
+
* its ancestor elements has its aria-hidden attribute set to true.
|
|
151
|
+
*/
|
|
152
|
+
// 🚫 Can't detect the element is focused.
|
|
153
|
+
// results.push(true);
|
|
154
|
+
/**
|
|
155
|
+
* - Elements that are a valid target of an aria-activedescendant attribute.
|
|
156
|
+
*/
|
|
157
|
+
// TODO: Compute aria-activedescendant.
|
|
158
|
+
// results.push(true);
|
|
159
|
+
/**
|
|
160
|
+
* Elements that have an explicit role or a global WAI-ARIA attribute and
|
|
161
|
+
* do not have aria-hidden set to true.
|
|
162
|
+
* (See Excluding Elements in the Accessibility Tree for
|
|
163
|
+
* additional guidance on aria-hidden.)
|
|
164
|
+
*/
|
|
165
|
+
if (el.getAttribute('aria-hidden') !== 'true') {
|
|
166
|
+
const globalAria = (0, aria_specs_1.ariaSpecs)(specs, version).props.filter(prop => prop.isGlobal);
|
|
167
|
+
const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
|
|
168
|
+
// Has an explicit role
|
|
169
|
+
if (role && !role.isImplicit) {
|
|
170
|
+
results.push(true);
|
|
171
|
+
}
|
|
172
|
+
// Has a global WAI-ARIA attribute
|
|
173
|
+
for (const attr of Array.from(el.attributes)) {
|
|
174
|
+
if (globalAria.some(aria => aria.name === attr.localName)) {
|
|
175
|
+
results.push(true);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Elements that are not hidden and have an ID that is referenced
|
|
182
|
+
* by another element via a WAI-ARIA property.
|
|
183
|
+
*/
|
|
184
|
+
// TODO: Compute refering ID.
|
|
185
|
+
// results.push(true);
|
|
186
|
+
return results.includes(true);
|
|
187
|
+
}
|
|
188
|
+
function hasDisplayNodeOrVisibilityHidden(
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
190
|
+
el) {
|
|
191
|
+
const style = el.getAttribute('style');
|
|
192
|
+
if (!style) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
// TODO: Improve accuracy
|
|
196
|
+
return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
|
|
197
|
+
}
|
|
198
|
+
function isExposedElement(
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
200
|
+
el, specs) {
|
|
201
|
+
var _a;
|
|
202
|
+
const svgRenderedConditions = (_a = specs.def['#contentModels']['#SVGRenderable']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
203
|
+
if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return isNotMetaOrHiddenHTMLElement(el, specs);
|
|
207
|
+
}
|
|
208
|
+
function isNotMetaOrHiddenHTMLElement(
|
|
209
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
210
|
+
el, specs) {
|
|
211
|
+
var _a;
|
|
212
|
+
const metadataConditions = (_a = specs.def['#contentModels']['#metadata']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
213
|
+
if (metadataConditions && el.matches(metadataConditions)) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
return !el.matches('input[type=hidden i]');
|
|
217
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchesContextRole = void 0;
|
|
4
|
+
const get_computed_role_1 = require("./get-computed-role");
|
|
5
|
+
function matchesContextRole(conditions,
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
ownedEl, specs, version) {
|
|
8
|
+
return conditions.some(condition => matchesCondition(condition, ownedEl.parentElement, specs, version));
|
|
9
|
+
}
|
|
10
|
+
exports.matchesContextRole = matchesContextRole;
|
|
11
|
+
function matchesCondition(condition,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
13
|
+
parentEl, specs, version) {
|
|
14
|
+
const conditions = condition.split(/\s+>\s+/g).reverse();
|
|
15
|
+
while (conditions.length > 0) {
|
|
16
|
+
if (!parentEl) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const condition = conditions.shift();
|
|
20
|
+
const parentRole = (0, get_computed_role_1.getComputedRole)(specs, parentEl, version, true).role;
|
|
21
|
+
if (condition !== (parentRole === null || parentRole === void 0 ? void 0 : parentRole.name)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
parentEl = parentEl.parentElement;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
el, specs) {
|
|
8
|
+
return [
|
|
9
|
+
/**
|
|
10
|
+
* Interactive content
|
|
11
|
+
*
|
|
12
|
+
* @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
|
|
13
|
+
*/
|
|
14
|
+
...(0, get_selectors_by_content_model_category_1.getSelectorsByContentModelCategory)(specs, '#interactive'),
|
|
15
|
+
/**
|
|
16
|
+
* Interaction
|
|
17
|
+
*
|
|
18
|
+
* @see https://html.spec.whatwg.org/multipage/interaction.html
|
|
19
|
+
*/
|
|
20
|
+
'[tabindex]',
|
|
21
|
+
'[contenteditable]:not([contenteditable="false" i])',
|
|
22
|
+
].some(selector => el.matches(selector));
|
|
23
|
+
}
|
|
24
|
+
exports.mayBeFocusable = mayBeFocusable;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
+
export * from './constant/aria-version';
|
|
1
2
|
export * from './dom-traverse/accname-computation';
|
|
2
3
|
export * from './dom-traverse/get-attr-specs';
|
|
4
|
+
export * from './dom-traverse/get-computed-aria-props';
|
|
3
5
|
export * from './dom-traverse/get-computed-role';
|
|
6
|
+
export * from './dom-traverse/get-content-model';
|
|
4
7
|
export * from './dom-traverse/get-implicit-role';
|
|
5
8
|
export * from './dom-traverse/get-permitted-roles';
|
|
6
9
|
export * from './dom-traverse/get-spec';
|
|
7
10
|
export * from './dom-traverse/has-required-owned-elements';
|
|
11
|
+
export * from './dom-traverse/is-exposed';
|
|
12
|
+
export * from './dom-traverse/may-be-focusable';
|
|
8
13
|
export * from './specs/aria-specs';
|
|
9
14
|
export * from './specs/content-model-category-to-tag-names';
|
|
15
|
+
export * from './specs/get-aria';
|
|
10
16
|
export * from './specs/get-role-spec';
|
|
11
17
|
export * from './specs/get-spec-by-tag-name';
|
|
18
|
+
export * from './specs/is-nothing-content-model';
|
|
19
|
+
export * from './specs/is-palpable-elements';
|
|
20
|
+
export * from './specs/is-void-element';
|
|
12
21
|
export * from './specs/schema-to-spec';
|
|
13
22
|
export * from './types';
|
|
14
23
|
export * from './types/aria';
|
|
15
24
|
export * from './types/attributes';
|
|
16
|
-
export * from './types/permitted-
|
|
25
|
+
export * from './types/permitted-structures';
|
|
17
26
|
export * from './utils/resolve-namespace';
|
|
27
|
+
export * from './utils/validateAriaVersion';
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./constant/aria-version"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./dom-traverse/accname-computation"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./dom-traverse/get-attr-specs"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./dom-traverse/get-computed-aria-props"), exports);
|
|
6
8
|
tslib_1.__exportStar(require("./dom-traverse/get-computed-role"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./dom-traverse/get-content-model"), exports);
|
|
7
10
|
tslib_1.__exportStar(require("./dom-traverse/get-implicit-role"), exports);
|
|
8
11
|
tslib_1.__exportStar(require("./dom-traverse/get-permitted-roles"), exports);
|
|
9
12
|
tslib_1.__exportStar(require("./dom-traverse/get-spec"), exports);
|
|
10
13
|
tslib_1.__exportStar(require("./dom-traverse/has-required-owned-elements"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./dom-traverse/is-exposed"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./dom-traverse/may-be-focusable"), exports);
|
|
11
16
|
tslib_1.__exportStar(require("./specs/aria-specs"), exports);
|
|
12
17
|
tslib_1.__exportStar(require("./specs/content-model-category-to-tag-names"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./specs/get-aria"), exports);
|
|
13
19
|
tslib_1.__exportStar(require("./specs/get-role-spec"), exports);
|
|
14
20
|
tslib_1.__exportStar(require("./specs/get-spec-by-tag-name"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./specs/is-nothing-content-model"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./specs/is-palpable-elements"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./specs/is-void-element"), exports);
|
|
15
24
|
tslib_1.__exportStar(require("./specs/schema-to-spec"), exports);
|
|
16
25
|
tslib_1.__exportStar(require("./types"), exports);
|
|
17
26
|
tslib_1.__exportStar(require("./types/aria"), exports);
|
|
18
27
|
tslib_1.__exportStar(require("./types/attributes"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./types/permitted-
|
|
28
|
+
tslib_1.__exportStar(require("./types/permitted-structures"), exports);
|
|
20
29
|
tslib_1.__exportStar(require("./utils/resolve-namespace"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./utils/validateAriaVersion"), exports);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function ariaSpecs(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function ariaSpecs(
|
|
3
|
+
specs: MLMLSpec,
|
|
4
|
+
version: ARIAVersion,
|
|
5
|
+
): {
|
|
6
|
+
readonly roles: readonly import('../types').ARIARoleInSchema[];
|
|
7
|
+
readonly graphicsRoles: readonly import('../types').ARIARoleInSchema[];
|
|
8
|
+
readonly props: readonly import('../types').ARIAProperty[];
|
|
6
9
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
import type { Category } from '../types/permitted-
|
|
3
|
-
export declare function contentModelCategoryToTagNames(
|
|
2
|
+
import type { Category } from '../types/permitted-structures';
|
|
3
|
+
export declare function contentModelCategoryToTagNames(
|
|
4
|
+
contentModel: Category,
|
|
5
|
+
def: MLMLSpec['def'],
|
|
6
|
+
): ReadonlyArray<string>;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contentModelCategoryToTagNames = void 0;
|
|
4
4
|
const cache = new Map();
|
|
5
|
-
function contentModelCategoryToTagNames(contentModel,
|
|
5
|
+
function contentModelCategoryToTagNames(contentModel, def) {
|
|
6
6
|
const cached = cache.get(contentModel);
|
|
7
7
|
if (cached) {
|
|
8
8
|
return cached;
|
|
9
9
|
}
|
|
10
|
-
const tags =
|
|
10
|
+
const tags = def['#contentModels'][contentModel];
|
|
11
11
|
const sortedTag = Object.freeze(tags && Array.isArray(tags) ? tags.sort() : []);
|
|
12
12
|
cache.set(contentModel, sortedTag);
|
|
13
13
|
return sortedTag;
|
package/lib/specs/get-aria.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
2
|
import type { ARIA } from '../types/aria';
|
|
3
|
-
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
4
|
+
export declare function getARIA(
|
|
5
|
+
specs: MLMLSpec,
|
|
6
|
+
localName: string,
|
|
7
|
+
namespace: string | null,
|
|
8
|
+
version: ARIAVersion,
|
|
9
|
+
matches: Matches,
|
|
10
|
+
): Omit<ReadonlyDeep<ARIA>, ARIAVersion | 'conditions'> | null;
|
package/lib/specs/get-aria.js
CHANGED
|
@@ -14,13 +14,16 @@ function getARIA(specs, localName, namespace, version, matches) {
|
|
|
14
14
|
if (!conditions) {
|
|
15
15
|
return aria;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const conditionKeys = Object.keys(conditions);
|
|
18
18
|
let { implicitRole, permittedRoles, implicitProperties, properties, namingProhibited } = aria;
|
|
19
|
-
for (const cond of
|
|
19
|
+
for (const cond of conditionKeys) {
|
|
20
20
|
if (!matches(cond)) {
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
23
|
const condARIA = conditions[cond];
|
|
24
|
+
if (!condARIA) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
24
27
|
implicitRole = (_a = condARIA.implicitRole) !== null && _a !== void 0 ? _a : implicitRole;
|
|
25
28
|
permittedRoles = (_b = condARIA.permittedRoles) !== null && _b !== void 0 ? _b : permittedRoles;
|
|
26
29
|
implicitProperties = (_c = condARIA.implicitProperties) !== null && _c !== void 0 ? _c : implicitProperties;
|
|
@@ -43,14 +46,17 @@ function getVersionResolvedARIA(specs, localName, namespace, version) {
|
|
|
43
46
|
if (aria !== undefined) {
|
|
44
47
|
return aria;
|
|
45
48
|
}
|
|
46
|
-
const spec = (_a = (0, get_spec_by_tag_name_1.getSpecByTagName)(specs, localName, namespace)) === null || _a === void 0 ? void 0 : _a.aria;
|
|
49
|
+
const spec = (_a = (0, get_spec_by_tag_name_1.getSpecByTagName)(specs.specs, localName, namespace)) === null || _a === void 0 ? void 0 : _a.aria;
|
|
47
50
|
if (!spec) {
|
|
48
51
|
cache.set(key, null);
|
|
49
52
|
return null;
|
|
50
53
|
}
|
|
51
54
|
aria = (0, resolve_version_1.resolveVersion)(spec, version);
|
|
52
|
-
if (aria.permittedRoles) {
|
|
53
|
-
aria
|
|
55
|
+
if (aria.permittedRoles !== false) {
|
|
56
|
+
aria = {
|
|
57
|
+
...aria,
|
|
58
|
+
permittedRoles: optimizePermittedRoles(aria.permittedRoles),
|
|
59
|
+
};
|
|
54
60
|
}
|
|
55
61
|
cache.set(key, aria);
|
|
56
62
|
return aria;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { MLMLSpec, Attribute } from '../types';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getAttrSpecs(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function getAttrSpecs(
|
|
4
|
+
localName: string,
|
|
5
|
+
namespace: NamespaceURI | null,
|
|
6
|
+
schema: MLMLSpec,
|
|
7
|
+
): readonly Attribute[] | null;
|
|
8
|
+
type HasName = {
|
|
9
|
+
readonly name: string;
|
|
6
10
|
};
|
|
7
11
|
export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
|
|
8
12
|
export {};
|
|
@@ -8,7 +8,7 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
8
8
|
if (!schemaCache.has(schema)) {
|
|
9
9
|
cacheMap.clear();
|
|
10
10
|
}
|
|
11
|
-
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace
|
|
11
|
+
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace !== null && namespace !== void 0 ? namespace : undefined);
|
|
12
12
|
const cache = cacheMap.get(localNameWithNS);
|
|
13
13
|
if (cache !== undefined) {
|
|
14
14
|
return cache;
|
|
@@ -24,7 +24,7 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
24
24
|
for (const catName in elSpec.globalAttrs) {
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
const catAttrs = elSpec.globalAttrs[catName];
|
|
27
|
-
if (
|
|
27
|
+
if (catAttrs === false) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
30
|
if (typeof catAttrs === 'boolean') {
|
|
@@ -66,18 +66,6 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
66
66
|
const attr = attrs[name];
|
|
67
67
|
return { name, type: 'Any', ...attr };
|
|
68
68
|
});
|
|
69
|
-
for (const attr of attrList) {
|
|
70
|
-
if (!attr.type) {
|
|
71
|
-
throw new Error(`The type is empty in the ${attr.name} attribute of the ${localName} element,
|
|
72
|
-
'packages',
|
|
73
|
-
'@markuplint',
|
|
74
|
-
'html-spec',
|
|
75
|
-
'src',
|
|
76
|
-
'attributes',
|
|
77
|
-
nameWithNS.replace(':', '_') + '.json',
|
|
78
|
-
)})`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
69
|
attrList.sort(nameCompare);
|
|
82
70
|
cacheMap.set(localNameWithNS, attrList);
|
|
83
71
|
return attrList;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(
|
|
2
|
+
export declare function getImplicitRole(
|
|
3
|
+
specs: MLMLSpec,
|
|
4
|
+
localName: string,
|
|
5
|
+
namespace: string | null,
|
|
6
|
+
version: ARIAVersion,
|
|
7
|
+
matches: Matches,
|
|
8
|
+
): import('..').ImplicitRole;
|
|
@@ -6,7 +6,13 @@ import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
|
6
6
|
* - If `true`, this mean is "Any".
|
|
7
7
|
* - If `false`, this mean is "No".
|
|
8
8
|
*/
|
|
9
|
-
export declare function getPermittedRoles(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export declare function getPermittedRoles(
|
|
10
|
+
specs: MLMLSpec,
|
|
11
|
+
localName: string,
|
|
12
|
+
namespace: string | null,
|
|
13
|
+
version: ARIAVersion,
|
|
14
|
+
matches: Matches,
|
|
15
|
+
): readonly {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly deprecated?: boolean;
|
|
12
18
|
}[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPermittedRoles = void 0;
|
|
4
|
+
const is_plain_object_1 = require("is-plain-object");
|
|
4
5
|
const merge_array_1 = require("../utils/merge-array");
|
|
5
6
|
const aria_specs_1 = require("./aria-specs");
|
|
6
7
|
const get_aria_1 = require("./get-aria");
|
|
@@ -26,17 +27,7 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
26
27
|
name: role.name,
|
|
27
28
|
})));
|
|
28
29
|
}
|
|
29
|
-
if (
|
|
30
|
-
permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
|
|
31
|
-
if (typeof role === 'string') {
|
|
32
|
-
return {
|
|
33
|
-
name: role,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return role;
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
else if (!(typeof permittedRoles === 'boolean')) {
|
|
30
|
+
if (isAAMInfo(permittedRoles)) {
|
|
40
31
|
if (permittedRoles['core-aam']) {
|
|
41
32
|
permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, roles
|
|
42
33
|
.filter(role => !role.isAbstract)
|
|
@@ -52,10 +43,23 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
52
43
|
})));
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
else if (typeof permittedRoles !== 'boolean') {
|
|
47
|
+
permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
|
|
48
|
+
if (typeof role === 'string') {
|
|
49
|
+
return {
|
|
50
|
+
name: role,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return role;
|
|
54
|
+
}));
|
|
58
55
|
}
|
|
59
|
-
|
|
56
|
+
if (implicitRole === false) {
|
|
57
|
+
return permittedRoleList;
|
|
58
|
+
}
|
|
59
|
+
const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
|
|
60
|
+
return (0, merge_array_1.mergeArray)(implicitRoles.map(r => ({ name: r })), permittedRoleList);
|
|
60
61
|
}
|
|
61
62
|
exports.getPermittedRoles = getPermittedRoles;
|
|
63
|
+
function isAAMInfo(permittedRoles) {
|
|
64
|
+
return (0, is_plain_object_1.isPlainObject)(permittedRoles);
|
|
65
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getRoleSpec(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function getRoleSpec(
|
|
4
|
+
specs: MLMLSpec,
|
|
5
|
+
roleName: string,
|
|
6
|
+
namespace: NamespaceURI,
|
|
7
|
+
version: ARIAVersion,
|
|
8
|
+
):
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
superClassRoles: ARIARoleInSchema[];
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
@@ -38,9 +38,9 @@ function recursiveTraverseSuperClassRoles(specs, roleName, namespace, version) {
|
|
|
38
38
|
return roles;
|
|
39
39
|
}
|
|
40
40
|
function getSuperClassRoles(specs, roleName, namespace, version) {
|
|
41
|
-
var _a;
|
|
41
|
+
var _a, _b;
|
|
42
42
|
const role = getRoleByName(specs, roleName, namespace, version);
|
|
43
|
-
return (((_a = role === null || role === void 0 ? void 0 : role.generalization) === null || _a === void 0 ? void 0 : _a.map(roleName => getRoleByName(specs, roleName, namespace, version)).filter((role) => !!role))
|
|
43
|
+
return ((_b = (_a = role === null || role === void 0 ? void 0 : role.generalization) === null || _a === void 0 ? void 0 : _a.map(roleName => getRoleByName(specs, roleName, namespace, version)).filter((role) => !!role)) !== null && _b !== void 0 ? _b : null);
|
|
44
44
|
}
|
|
45
45
|
function getRoleByName(specs, roleName, namespace, version) {
|
|
46
46
|
const { roles, graphicsRoles } = (0, aria_specs_1.ariaSpecs)(specs, version);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
import type { Category } from '../types/permitted-
|
|
3
|
-
export declare function getSelectorsByContentModelCategory(specs:
|
|
2
|
+
import type { Category } from '../types/permitted-structures';
|
|
3
|
+
export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSelectorsByContentModelCategory = void 0;
|
|
4
4
|
function getSelectorsByContentModelCategory(specs, category) {
|
|
5
5
|
const selectors = specs.def['#contentModels'][category];
|
|
6
|
-
return selectors
|
|
6
|
+
return selectors !== null && selectors !== void 0 ? selectors : [];
|
|
7
7
|
}
|
|
8
8
|
exports.getSelectorsByContentModelCategory = getSelectorsByContentModelCategory;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type { ElementSpec
|
|
2
|
-
export declare function getSpecByTagName
|
|
1
|
+
import type { ElementSpec } from '../types';
|
|
2
|
+
export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(
|
|
3
|
+
specs: readonly Pick<ElementSpec, 'name' | K>[],
|
|
4
|
+
localName: string,
|
|
5
|
+
namespace: string | null,
|
|
6
|
+
): Pick<ElementSpec, 'name' | K> | null;
|