@markuplint/ml-spec 3.0.0-canary.5 → 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 +1 -1
- 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 +6 -6
- package/lib/dom-traverse/get-computed-aria-props.js +4 -2
- package/lib/dom-traverse/get-computed-role.d.ts +6 -1
- package/lib/dom-traverse/get-computed-role.js +41 -10
- package/lib/dom-traverse/get-content-model.d.ts +28 -2
- package/lib/dom-traverse/get-content-model.js +4 -2
- 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 +4 -1
- package/lib/dom-traverse/get-spec.js +3 -1
- package/lib/dom-traverse/has-required-owned-elements.d.ts +8 -2
- package/lib/dom-traverse/has-required-owned-elements.js +14 -8
- package/lib/dom-traverse/is-exposed.d.ts +1 -1
- package/lib/dom-traverse/is-exposed.js +43 -7
- 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 +1 -1
- package/lib/dom-traverse/may-be-focusable.js +3 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/specs/aria-specs.d.ts +7 -4
- package/lib/specs/content-model-category-to-tag-names.d.ts +4 -1
- package/lib/specs/get-aria.d.ts +8 -1
- package/lib/specs/get-aria.js +8 -2
- package/lib/specs/get-attr-specs.d.ts +6 -2
- 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 +1 -1
- package/lib/specs/get-selectors-by-content-model-category.js +1 -1
- package/lib/specs/get-spec-by-tag-name.d.ts +5 -1
- 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 +8 -4
- package/lib/specs/is-palpable-elements.js +6 -4
- package/lib/specs/is-void-element.js +3 -1
- 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 +149 -114
- package/lib/types/attributes.d.ts +1490 -111
- package/lib/types/index.d.ts +178 -149
- package/lib/types/permitted-structures.d.ts +74 -31
- package/lib/utils/merge-array.d.ts +9 -4
- package/lib/utils/resolve-namespace.d.ts +4 -4
- package/lib/utils/resolve-namespace.js +3 -2
- package/lib/utils/validateAriaVersion.d.ts +2 -0
- package/lib/utils/validateAriaVersion.js +8 -0
- package/package.json +13 -8
- package/{src/dom-traverse/accname-computation.spec.ts → test/dom-traverse/accname-computation.spec.js} +4 -4
- 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/{src/dom-traverse/is-exposed.spec.ts → test/dom-traverse/is-exposed.spec.js} +29 -9
- 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} +2 -2
- package/test/specs/resolve-version.spec.js +34 -0
- package/test/specs/schema-to-spec.spec.js +61 -0
- package/{src/utils/resolve-namespace.spec.ts → test/utils/resolve-namespace.spec.js} +1 -1
- package/lib/types/permitted-structres.d.ts +0 -58
- package/lib/types/permitted-structres.js +0 -8
- package/schemas/aria.schema.json +0 -258
- package/schemas/attributes.schema.json +0 -204
- package/schemas/content-models.schema.json +0 -199
- package/schemas/element.schema.json +0 -11
- package/schemas/global-attributes.schema.json +0 -761
- package/src/dom-traverse/accname-computation.ts +0 -5
- package/src/dom-traverse/get-attr-specs.ts +0 -8
- package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
- package/src/dom-traverse/get-computed-aria-props.ts +0 -130
- package/src/dom-traverse/get-computed-role.spec.ts +0 -134
- package/src/dom-traverse/get-computed-role.ts +0 -181
- package/src/dom-traverse/get-content-model.ts +0 -32
- package/src/dom-traverse/get-explicit-role.ts +0 -112
- package/src/dom-traverse/get-implicit-role.ts +0 -36
- package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
- package/src/dom-traverse/get-permitted-roles.ts +0 -7
- package/src/dom-traverse/get-spec.ts +0 -7
- package/src/dom-traverse/has-required-owned-elements.ts +0 -85
- package/src/dom-traverse/is-exposed.ts +0 -196
- package/src/dom-traverse/may-be-focusable.ts +0 -21
- package/src/index.ts +0 -23
- 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 -20
- package/src/specs/is-palpable-elements.ts +0 -55
- package/src/specs/is-presentational.ts +0 -6
- package/src/specs/is-void-element.ts +0 -22
- package/src/specs/resolve-version.ts +0 -20
- package/src/specs/schema-to-spec.spec.ts +0 -39
- package/src/specs/schema-to-spec.ts +0 -103
- package/src/types/aria.ts +0 -153
- package/src/types/attributes.ts +0 -1473
- package/src/types/index.ts +0 -255
- package/src/types/permitted-structres.ts +0 -100
- package/src/types/permitted-structures.ts +0 -96
- package/src/utils/get-ns.ts +0 -18
- package/src/utils/merge-array.ts +0 -35
- package/src/utils/resolve-namespace.ts +0 -40
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { ElementSpec, ExtendedSpec, MLMLSpec, Attribute } from '../types';
|
|
2
|
-
|
|
3
|
-
import { mergeArray } from '../utils/merge-array';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Merging HTML-spec schema and extended spec schemas
|
|
7
|
-
*
|
|
8
|
-
* Ex: `@markuplint/html-spec` + `{ specs: ["@markuplint/vue-spec"] }` in configure files.
|
|
9
|
-
*
|
|
10
|
-
* @param schemas `MLDocument.schemas`
|
|
11
|
-
*/
|
|
12
|
-
export function schemaToSpec(schemas: readonly [MLMLSpec, ...ExtendedSpec[]]) {
|
|
13
|
-
const [main, ...extendedSpecs] = schemas;
|
|
14
|
-
const result = { ...main };
|
|
15
|
-
for (const extendedSpec of extendedSpecs) {
|
|
16
|
-
if (extendedSpec.cites) {
|
|
17
|
-
result.cites = [...result.cites, ...extendedSpec.cites];
|
|
18
|
-
}
|
|
19
|
-
if (extendedSpec.def) {
|
|
20
|
-
if (extendedSpec.def['#globalAttrs']?.['#extends']) {
|
|
21
|
-
result.def['#globalAttrs']['#HTMLGlobalAttrs'] = {
|
|
22
|
-
...(result.def['#globalAttrs']?.['#HTMLGlobalAttrs'] || {}),
|
|
23
|
-
...(extendedSpec.def['#globalAttrs']?.['#extends'] || {}),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (extendedSpec.def['#aria']) {
|
|
27
|
-
result.def['#aria'] = {
|
|
28
|
-
'1.1': {
|
|
29
|
-
roles: mergeArray(result.def['#aria']['1.1'].roles, extendedSpec.def['#aria']['1.1'].roles),
|
|
30
|
-
props: mergeArray(result.def['#aria']['1.1'].props, extendedSpec.def['#aria']['1.1'].props),
|
|
31
|
-
graphicsRoles: mergeArray(
|
|
32
|
-
result.def['#aria']['1.1'].graphicsRoles,
|
|
33
|
-
extendedSpec.def['#aria']['1.1'].graphicsRoles,
|
|
34
|
-
),
|
|
35
|
-
},
|
|
36
|
-
'1.2': {
|
|
37
|
-
roles: mergeArray(result.def['#aria']['1.2'].roles, extendedSpec.def['#aria']['1.2'].roles),
|
|
38
|
-
props: mergeArray(result.def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
|
|
39
|
-
graphicsRoles: mergeArray(
|
|
40
|
-
result.def['#aria']['1.2'].graphicsRoles,
|
|
41
|
-
extendedSpec.def['#aria']['1.2'].graphicsRoles,
|
|
42
|
-
),
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (extendedSpec.def['#contentModels']) {
|
|
47
|
-
const keys = new Set([
|
|
48
|
-
...Object.keys(result.def['#contentModels']),
|
|
49
|
-
...Object.keys(extendedSpec.def['#contentModels']),
|
|
50
|
-
]) as Set<keyof typeof result.def['#contentModels']>;
|
|
51
|
-
for (const modelName of keys) {
|
|
52
|
-
const mainModel = result.def['#contentModels'][modelName];
|
|
53
|
-
const exModel = extendedSpec.def['#contentModels'][modelName];
|
|
54
|
-
result.def['#contentModels'][modelName] = [...(mainModel || []), ...(exModel || [])];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (extendedSpec.specs) {
|
|
59
|
-
const exSpecs = extendedSpec.specs.slice();
|
|
60
|
-
const specs: ElementSpec[] = [];
|
|
61
|
-
for (const elSpec of result.specs) {
|
|
62
|
-
const tagName = elSpec.name.toLowerCase();
|
|
63
|
-
const index = exSpecs.findIndex(spec => spec.name.toLowerCase() === tagName);
|
|
64
|
-
if (index === -1) {
|
|
65
|
-
specs.push(elSpec);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
const exSpec = exSpecs.splice(index, 1)[0];
|
|
69
|
-
specs.push({
|
|
70
|
-
...elSpec,
|
|
71
|
-
...exSpec,
|
|
72
|
-
globalAttrs: {
|
|
73
|
-
...elSpec.globalAttrs,
|
|
74
|
-
...exSpec.globalAttrs,
|
|
75
|
-
},
|
|
76
|
-
attributes: mergeAttrSpec(elSpec.attributes, exSpec.attributes),
|
|
77
|
-
categories: mergeArray(elSpec.categories, exSpec.categories),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
result.specs = specs;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function mergeAttrSpec(
|
|
89
|
-
std: Record<string, Attribute>,
|
|
90
|
-
ex: Record<string, Partial<Attribute>> = {},
|
|
91
|
-
): Record<string, Attribute> {
|
|
92
|
-
const result: Record<string, Attribute> = {};
|
|
93
|
-
const keys = Array.from(new Set([...Object.keys(std), ...Object.keys(ex)]));
|
|
94
|
-
for (const key of keys) {
|
|
95
|
-
const _std = std[key];
|
|
96
|
-
const _ex = ex[key];
|
|
97
|
-
result[key] = {
|
|
98
|
-
..._std,
|
|
99
|
-
..._ex,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return result;
|
|
103
|
-
}
|
package/src/types/aria.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/**
|
|
3
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* If `false`, this mean is "No corresponding role".
|
|
10
|
-
*/
|
|
11
|
-
export type ImplicitRole = false | string;
|
|
12
|
-
/**
|
|
13
|
-
* If `true`, this mean is "Any". If `false`, this mean is "No".
|
|
14
|
-
*/
|
|
15
|
-
export type PermittedRoles =
|
|
16
|
-
| boolean
|
|
17
|
-
| (
|
|
18
|
-
| string
|
|
19
|
-
| {
|
|
20
|
-
name: string;
|
|
21
|
-
deprecated?: true;
|
|
22
|
-
[k: string]: unknown;
|
|
23
|
-
}
|
|
24
|
-
)[]
|
|
25
|
-
| {
|
|
26
|
-
'core-aam'?: true;
|
|
27
|
-
'graphics-aam'?: true;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* If set false:
|
|
31
|
-
* > No role or aria-* attributes
|
|
32
|
-
*/
|
|
33
|
-
export type PermittedARIAProperties =
|
|
34
|
-
| false
|
|
35
|
-
| {
|
|
36
|
-
global?: true;
|
|
37
|
-
/**
|
|
38
|
-
* Set true if the spec says "and any aria-* attributes applicable to the allowed roles."
|
|
39
|
-
*/
|
|
40
|
-
role?: true | string | [string, ...string[]];
|
|
41
|
-
/**
|
|
42
|
-
* @minItems 1
|
|
43
|
-
*/
|
|
44
|
-
only?: [
|
|
45
|
-
(
|
|
46
|
-
| string
|
|
47
|
-
| {
|
|
48
|
-
name: string;
|
|
49
|
-
value?: string;
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
...(
|
|
53
|
-
| string
|
|
54
|
-
| {
|
|
55
|
-
name: string;
|
|
56
|
-
value?: string;
|
|
57
|
-
}
|
|
58
|
-
)[],
|
|
59
|
-
];
|
|
60
|
-
/**
|
|
61
|
-
* @minItems 1
|
|
62
|
-
*/
|
|
63
|
-
without?: [
|
|
64
|
-
{
|
|
65
|
-
type: 'not-recommended' | 'should-not' | 'must-not';
|
|
66
|
-
name: string;
|
|
67
|
-
value?: string;
|
|
68
|
-
alt?: {
|
|
69
|
-
method: 'remove-attr' | 'set-attr';
|
|
70
|
-
target: string;
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
...{
|
|
74
|
-
type: 'not-recommended' | 'should-not' | 'must-not';
|
|
75
|
-
name: string;
|
|
76
|
-
value?: string;
|
|
77
|
-
alt?: {
|
|
78
|
-
method: 'remove-attr' | 'set-attr';
|
|
79
|
-
target: string;
|
|
80
|
-
};
|
|
81
|
-
}[],
|
|
82
|
-
];
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export interface AriaSchema {
|
|
86
|
-
_?: ARIA;
|
|
87
|
-
[k: string]: unknown;
|
|
88
|
-
}
|
|
89
|
-
export interface ARIA {
|
|
90
|
-
implicitRole: ImplicitRole;
|
|
91
|
-
permittedRoles: PermittedRoles;
|
|
92
|
-
namingProhibited?: true;
|
|
93
|
-
implicitProperties?: ImplicitProperties;
|
|
94
|
-
properties?: PermittedARIAProperties;
|
|
95
|
-
conditions?: {
|
|
96
|
-
/**
|
|
97
|
-
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
98
|
-
* via the `patternProperty` ".+".
|
|
99
|
-
*/
|
|
100
|
-
[k: string]: {
|
|
101
|
-
implicitRole?: ImplicitRole;
|
|
102
|
-
permittedRoles?: PermittedRoles;
|
|
103
|
-
namingProhibited?: true;
|
|
104
|
-
implicitProperties?: ImplicitProperties;
|
|
105
|
-
properties?: PermittedARIAProperties;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
'1.2'?: {
|
|
109
|
-
implicitRole?: ImplicitRole;
|
|
110
|
-
permittedRoles?: PermittedRoles;
|
|
111
|
-
namingProhibited?: true;
|
|
112
|
-
implicitProperties?: ImplicitProperties;
|
|
113
|
-
properties?: PermittedARIAProperties;
|
|
114
|
-
conditions?: {
|
|
115
|
-
/**
|
|
116
|
-
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
117
|
-
* via the `patternProperty` ".+".
|
|
118
|
-
*/
|
|
119
|
-
[k: string]: {
|
|
120
|
-
implicitRole?: ImplicitRole;
|
|
121
|
-
permittedRoles?: PermittedRoles;
|
|
122
|
-
namingProhibited?: true;
|
|
123
|
-
implicitProperties?: ImplicitProperties;
|
|
124
|
-
properties?: PermittedARIAProperties;
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
'1.1'?: {
|
|
129
|
-
implicitRole?: ImplicitRole;
|
|
130
|
-
permittedRoles?: PermittedRoles;
|
|
131
|
-
implicitProperties?: ImplicitProperties;
|
|
132
|
-
properties?: PermittedARIAProperties;
|
|
133
|
-
conditions?: {
|
|
134
|
-
/**
|
|
135
|
-
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
136
|
-
* via the `patternProperty` ".+".
|
|
137
|
-
*/
|
|
138
|
-
[k: string]: {
|
|
139
|
-
implicitRole?: ImplicitRole;
|
|
140
|
-
permittedRoles?: PermittedRoles;
|
|
141
|
-
implicitProperties?: ImplicitProperties;
|
|
142
|
-
properties?: PermittedARIAProperties;
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
export interface ImplicitProperties {
|
|
148
|
-
/**
|
|
149
|
-
* This interface was referenced by `ImplicitProperties`'s JSON-Schema definition
|
|
150
|
-
* via the `patternProperty` "^aria-.+".
|
|
151
|
-
*/
|
|
152
|
-
[k: string]: string;
|
|
153
|
-
}
|