@markuplint/ml-spec 4.0.0-alpha.3 → 4.0.0-dev.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dom-traverse/get-computed-aria-props.js +6 -6
- package/lib/dom-traverse/get-computed-role.js +9 -11
- package/lib/dom-traverse/has-required-owned-elements.js +1 -1
- package/lib/dom-traverse/is-exposed.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/specs/get-aria.js +1 -1
- package/lib/specs/get-attr-specs.js +2 -2
- package/lib/specs/is-void-element.js +3 -3
- package/lib/specs/schema-to-spec.js +4 -4
- package/lib/utils/merge-array.js +1 -1
- package/package.json +5 -6
- /package/lib/utils/{validateAriaVersion.d.ts → validate-aria-version.d.ts} +0 -0
- /package/lib/utils/{validateAriaVersion.js → validate-aria-version.js} +0 -0
|
@@ -9,10 +9,10 @@ el, version) {
|
|
|
9
9
|
return {};
|
|
10
10
|
}
|
|
11
11
|
const props = {};
|
|
12
|
-
role.ownedProperties
|
|
12
|
+
for (const ownedProp of role.ownedProperties) {
|
|
13
13
|
const spec = ariaSpecs.props.find(propSpec => propSpec.name === ownedProp.name);
|
|
14
14
|
if (!spec) {
|
|
15
|
-
|
|
15
|
+
continue;
|
|
16
16
|
}
|
|
17
17
|
if (el.hasAttribute(spec.name)) {
|
|
18
18
|
const attrValue = el.getAttribute(spec.name);
|
|
@@ -24,7 +24,7 @@ el, version) {
|
|
|
24
24
|
required: !!ownedProp.required,
|
|
25
25
|
from: 'aria-attr',
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
continue;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
const equivalentHtmlAttr = spec.equivalentHtmlAttrs?.[0];
|
|
@@ -40,7 +40,7 @@ el, version) {
|
|
|
40
40
|
required: !!ownedProp.required,
|
|
41
41
|
from: 'html-attr',
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
continue;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
let defaultValue = spec.defaultValue;
|
|
@@ -57,7 +57,7 @@ el, version) {
|
|
|
57
57
|
required: !!ownedProp.required,
|
|
58
58
|
from: 'default',
|
|
59
59
|
};
|
|
60
|
-
}
|
|
60
|
+
}
|
|
61
61
|
return props;
|
|
62
62
|
}
|
|
63
63
|
function isValidAriaValue(spec, role, value, enumList) {
|
|
@@ -81,7 +81,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
81
81
|
}
|
|
82
82
|
case 'integer':
|
|
83
83
|
case 'number': {
|
|
84
|
-
return !isNaN(parseFloat(value));
|
|
84
|
+
return !Number.isNaN(Number.parseFloat(value));
|
|
85
85
|
}
|
|
86
86
|
case 'token':
|
|
87
87
|
case 'token list': {
|
|
@@ -116,9 +116,7 @@ el, version, assumeSingleNode = false) {
|
|
|
116
116
|
// It is an SVG element.
|
|
117
117
|
el.namespaceURI === 'http://www.w3.org/2000/svg') {
|
|
118
118
|
const accname = getAccname(el).trim() ||
|
|
119
|
-
|
|
120
|
-
.find(child => ['title', 'desc'].includes(child.localName))
|
|
121
|
-
?.textContent?.trim();
|
|
119
|
+
[...el.children].find(child => ['title', 'desc'].includes(child.localName))?.textContent?.trim();
|
|
122
120
|
if (!accname) {
|
|
123
121
|
return {
|
|
124
122
|
el,
|
|
@@ -181,18 +179,18 @@ el, version, assumeSingleNode = false) {
|
|
|
181
179
|
*/
|
|
182
180
|
if (explicitRole.role) {
|
|
183
181
|
const nonPresentationalAncestor = getNonPresentationalAncestor(el, specs, version);
|
|
184
|
-
if (nonPresentationalAncestor.role &&
|
|
185
|
-
|
|
182
|
+
if (nonPresentationalAncestor.role &&
|
|
183
|
+
nonPresentationalAncestor.role?.requiredOwnedElements.length > 0 &&
|
|
184
|
+
nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
|
|
186
185
|
// const ancestor = nonPresentationalAncestor.el;
|
|
187
186
|
// const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
|
|
188
187
|
// console.log({ nonPresentationalAncestor, ancestorImplicitRole });
|
|
189
188
|
return isRequiredOwnedElement(implicitRole.el, implicitRole.role, expected, specs, version);
|
|
190
189
|
})) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
190
|
+
return {
|
|
191
|
+
...implicitRole,
|
|
192
|
+
errorType: 'REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL',
|
|
193
|
+
};
|
|
196
194
|
}
|
|
197
195
|
}
|
|
198
196
|
/**
|
|
@@ -206,7 +204,7 @@ el, version, assumeSingleNode = false) {
|
|
|
206
204
|
* > and an explicit non-presentational role is applied.
|
|
207
205
|
*/
|
|
208
206
|
const { props } = ariaSpecs(specs, version);
|
|
209
|
-
for (const attr of
|
|
207
|
+
for (const attr of el.attributes) {
|
|
210
208
|
if (props.find(p => p.name === attr.name)?.isGlobal) {
|
|
211
209
|
return {
|
|
212
210
|
...implicitRole,
|
|
@@ -66,7 +66,7 @@ function getClosestNonPresentationalDescendants(
|
|
|
66
66
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
67
67
|
el, specs, version) {
|
|
68
68
|
const owned = [];
|
|
69
|
-
for (const child of
|
|
69
|
+
for (const child of el.children) {
|
|
70
70
|
const implicitRole = getImplicitRole(specs, child, version);
|
|
71
71
|
const explicitRole = getExplicitRole(specs, child, version);
|
|
72
72
|
const computed = explicitRole.role ? explicitRole : implicitRole;
|
|
@@ -165,7 +165,7 @@ el, specs, version) {
|
|
|
165
165
|
results.push(true);
|
|
166
166
|
}
|
|
167
167
|
// Has a global WAI-ARIA attribute
|
|
168
|
-
for (const attr of
|
|
168
|
+
for (const attr of el.attributes) {
|
|
169
169
|
if (globalAria.some(aria => aria.name === attr.localName)) {
|
|
170
170
|
results.push(true);
|
|
171
171
|
break;
|
package/lib/index.d.ts
CHANGED
|
@@ -25,4 +25,4 @@ export * from './types/aria.js';
|
|
|
25
25
|
export * from './types/attributes.js';
|
|
26
26
|
export * from './types/permitted-structures.js';
|
|
27
27
|
export * from './utils/resolve-namespace.js';
|
|
28
|
-
export * from './utils/
|
|
28
|
+
export * from './utils/validate-aria-version.js';
|
package/lib/index.js
CHANGED
|
@@ -25,4 +25,4 @@ export * from './types/aria.js';
|
|
|
25
25
|
export * from './types/attributes.js';
|
|
26
26
|
export * from './types/permitted-structures.js';
|
|
27
27
|
export * from './utils/resolve-namespace.js';
|
|
28
|
-
export * from './utils/
|
|
28
|
+
export * from './utils/validate-aria-version.js';
|
package/lib/specs/get-aria.js
CHANGED
|
@@ -37,13 +37,13 @@ export function getAttrSpecs(localName, namespace, schema) {
|
|
|
37
37
|
if (!global) {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
for (const selectedName of catAttrs) {
|
|
41
41
|
const selected = global[selectedName];
|
|
42
42
|
attrs[selectedName] = {
|
|
43
43
|
...attrs[selectedName],
|
|
44
44
|
...selected,
|
|
45
45
|
};
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @see https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
3
3
|
*/
|
|
4
|
-
const voidElements = [
|
|
4
|
+
const voidElements = new Set([
|
|
5
5
|
'area',
|
|
6
6
|
'base',
|
|
7
7
|
'br',
|
|
@@ -15,9 +15,9 @@ const voidElements = [
|
|
|
15
15
|
'source',
|
|
16
16
|
'track',
|
|
17
17
|
'wbr',
|
|
18
|
-
];
|
|
18
|
+
]);
|
|
19
19
|
export function isVoidElement(
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
21
21
|
el) {
|
|
22
|
-
return voidElements.
|
|
22
|
+
return voidElements.has(el.localName);
|
|
23
23
|
}
|
|
@@ -18,8 +18,8 @@ export function schemaToSpec(schemas) {
|
|
|
18
18
|
if (extendedSpec.def['#globalAttrs']?.['#extends']) {
|
|
19
19
|
const gAttrs = { ...def['#globalAttrs'] };
|
|
20
20
|
gAttrs['#HTMLGlobalAttrs'] = {
|
|
21
|
-
...
|
|
22
|
-
...
|
|
21
|
+
...def['#globalAttrs']?.['#HTMLGlobalAttrs'],
|
|
22
|
+
...extendedSpec.def['#globalAttrs']?.['#extends'],
|
|
23
23
|
};
|
|
24
24
|
def['#globalAttrs'] = gAttrs;
|
|
25
25
|
}
|
|
@@ -58,7 +58,7 @@ export function schemaToSpec(schemas) {
|
|
|
58
58
|
result.def = def;
|
|
59
59
|
}
|
|
60
60
|
if (extendedSpec.specs) {
|
|
61
|
-
const exSpecs = extendedSpec.specs
|
|
61
|
+
const exSpecs = [...extendedSpec.specs];
|
|
62
62
|
const specs = [];
|
|
63
63
|
for (const elSpec of result.specs) {
|
|
64
64
|
const tagName = elSpec.name.toLowerCase();
|
|
@@ -86,7 +86,7 @@ export function schemaToSpec(schemas) {
|
|
|
86
86
|
}
|
|
87
87
|
function mergeAttrSpec(std, ex = {}) {
|
|
88
88
|
const result = {};
|
|
89
|
-
const keys =
|
|
89
|
+
const keys = [...new Set([...Object.keys(std), ...Object.keys(ex)])];
|
|
90
90
|
for (const key of keys) {
|
|
91
91
|
const _std = std[key];
|
|
92
92
|
const _ex = ex[key];
|
package/lib/utils/merge-array.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-spec",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-dev.28+0131de5e",
|
|
4
4
|
"description": "Types and schema that specs of the Markup languages for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -30,16 +30,15 @@
|
|
|
30
30
|
"schema": "run-s schema:*"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@markuplint/ml-ast": "4.0.0-
|
|
34
|
-
"@markuplint/types": "4.0.0-
|
|
33
|
+
"@markuplint/ml-ast": "4.0.0-dev.28+0131de5e",
|
|
34
|
+
"@markuplint/types": "4.0.0-dev.28+0131de5e",
|
|
35
35
|
"dom-accessibility-api": "^0.6.3",
|
|
36
36
|
"is-plain-object": "^5.0.0",
|
|
37
|
-
"
|
|
38
|
-
"type-fest": "^4.3.1"
|
|
37
|
+
"type-fest": "^4.5.0"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
40
|
"@markuplint/test-tools": "4.0.0-alpha.3",
|
|
42
41
|
"json-schema-to-typescript": "13.1.1"
|
|
43
42
|
},
|
|
44
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "0131de5ea9dd6d3fd5472d7b414b66644c758881"
|
|
45
44
|
}
|
|
File without changes
|
|
File without changes
|