@markuplint/ml-spec 2.0.1 → 3.0.0-alpha.0
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/accname-computation.d.ts +1 -0
- package/lib/dom-traverse/accname-computation.js +8 -0
- package/lib/dom-traverse/focusability-computation.d.ts +1 -0
- package/lib/dom-traverse/focusability-computation.js +8 -0
- package/lib/dom-traverse/get-aria.d.ts +9 -0
- package/lib/dom-traverse/get-aria.js +54 -0
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -0
- package/lib/dom-traverse/get-attr-specs.js +8 -0
- package/lib/dom-traverse/get-computed-role.d.ts +2 -0
- package/lib/dom-traverse/get-computed-role.js +170 -0
- package/lib/dom-traverse/get-explicit-role.d.ts +2 -0
- package/lib/dom-traverse/get-explicit-role.js +102 -0
- package/lib/dom-traverse/get-implicit-role.d.ts +3 -0
- package/lib/dom-traverse/get-implicit-role.js +37 -0
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +5 -0
- package/lib/dom-traverse/get-non-presentational-ancestor.js +21 -0
- package/lib/dom-traverse/get-permitted-roles.d.ts +5 -0
- package/lib/dom-traverse/get-permitted-roles.js +8 -0
- package/lib/dom-traverse/get-spec.d.ts +2 -0
- package/lib/dom-traverse/get-spec.js +8 -0
- package/lib/dom-traverse/has-required-owned-elements.d.ts +3 -0
- package/lib/dom-traverse/has-required-owned-elements.js +81 -0
- package/lib/dom-traverse/may-be-focusable.d.ts +2 -0
- package/lib/dom-traverse/may-be-focusable.js +22 -0
- package/lib/index.d.ts +17 -6
- package/lib/index.js +18 -7
- package/lib/specs/aria-spec.d.ts +5 -0
- package/lib/specs/aria-spec.js +12 -0
- package/lib/specs/aria-specs.d.ts +6 -0
- package/lib/specs/aria-specs.js +8 -0
- package/lib/specs/content-model-category-to-tag-names.d.ts +3 -0
- package/lib/specs/content-model-category-to-tag-names.js +15 -0
- package/lib/specs/get-aria.d.ts +3 -0
- package/lib/specs/get-aria.js +71 -0
- package/lib/specs/get-attr-specs.d.ts +8 -0
- package/lib/{get-attr-specs.js → specs/get-attr-specs.js} +8 -6
- package/lib/specs/get-implicit-role.d.ts +2 -0
- package/lib/specs/get-implicit-role.js +12 -0
- package/lib/specs/get-permitted-roles.d.ts +12 -0
- package/lib/specs/get-permitted-roles.js +61 -0
- package/lib/specs/get-role-spec.d.ts +5 -0
- package/lib/specs/get-role-spec.js +52 -0
- package/lib/specs/get-selectors-by-content-model-category.d.ts +3 -0
- package/lib/specs/get-selectors-by-content-model-category.js +8 -0
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -0
- package/lib/specs/get-spec-by-tag-name.js +16 -0
- package/lib/{get-spec.d.ts → specs/get-spec.d.ts} +4 -4
- package/lib/{get-spec.js → specs/get-spec.js} +1 -1
- package/lib/specs/html-spec.d.ts +6 -0
- package/lib/specs/html-spec.js +16 -0
- package/lib/specs/is-presentational.d.ts +1 -0
- package/lib/specs/is-presentational.js +10 -0
- package/lib/specs/resolve-namespace.d.ts +9 -0
- package/lib/specs/resolve-namespace.js +26 -0
- package/lib/specs/resolve-version.d.ts +3 -0
- package/lib/specs/resolve-version.js +21 -0
- package/lib/specs/schema-to-spec.d.ts +13 -0
- package/lib/specs/schema-to-spec.js +93 -0
- package/lib/types/aria.d.ts +130 -0
- package/lib/{attributes.js → types/aria.js} +0 -0
- package/lib/{attributes.d.ts → types/attributes.d.ts} +5 -12
- package/lib/{permitted-structres.js → types/attributes.js} +0 -0
- package/lib/{types.d.ts → types/index.d.ts} +50 -65
- package/lib/{types.js → types/index.js} +0 -0
- package/lib/{permitted-structres.d.ts → types/permitted-structres.d.ts} +14 -23
- package/lib/types/permitted-structres.js +8 -0
- package/lib/utils/cache.d.ts +10 -0
- package/lib/utils/cache.js +42 -0
- package/lib/utils/get-ns.d.ts +2 -0
- package/lib/{get-ns.js → utils/get-ns.js} +3 -0
- package/lib/utils/merge-array.d.ts +5 -0
- package/lib/utils/merge-array.js +36 -0
- package/lib/utils/resolve-namespace.d.ts +9 -0
- package/lib/utils/resolve-namespace.js +31 -0
- package/lib/utils.d.ts +6 -3
- package/lib/utils.js +15 -1
- package/package.json +10 -6
- package/schemas/aria.schema.json +258 -0
- package/schemas/attributes.schema.json +5 -23
- package/schemas/{permitted-structures.schema.json → content-models.schema.json} +52 -81
- package/schemas/element.schema.json +11 -0
- package/schemas/global-attributes.schema.json +6 -2
- package/src/dom-traverse/accname-computation.spec.ts +69 -0
- package/src/dom-traverse/accname-computation.ts +5 -0
- package/src/dom-traverse/get-attr-specs.ts +8 -0
- package/src/dom-traverse/get-computed-role.spec.ts +134 -0
- package/src/dom-traverse/get-computed-role.ts +181 -0
- package/src/dom-traverse/get-explicit-role.ts +112 -0
- package/src/dom-traverse/get-implicit-role.ts +36 -0
- package/src/dom-traverse/get-non-presentational-ancestor.ts +20 -0
- package/src/dom-traverse/get-permitted-roles.ts +7 -0
- package/src/dom-traverse/get-spec.ts +7 -0
- package/src/dom-traverse/has-required-owned-elements.spec.ts +36 -0
- package/src/dom-traverse/has-required-owned-elements.ts +85 -0
- package/src/dom-traverse/may-be-focusable.ts +21 -0
- package/src/index.ts +17 -6
- package/src/specs/aria-specs.ts +6 -0
- package/src/specs/content-model-category-to-tag-names.ts +15 -0
- package/src/specs/get-aria.ts +85 -0
- package/src/{get-attr-specs.spec.ts → specs/get-attr-specs.spec.ts} +9 -6
- package/src/{get-attr-specs.ts → specs/get-attr-specs.ts} +12 -7
- package/src/specs/get-implicit-role.spec.ts +81 -0
- package/src/specs/get-implicit-role.ts +17 -0
- package/src/specs/get-permitted-roles.spec.ts +420 -0
- package/src/specs/get-permitted-roles.ts +87 -0
- package/src/specs/get-role-spec.spec.ts +67 -0
- package/src/specs/get-role-spec.ts +72 -0
- package/src/specs/get-selectors-by-content-model-category.ts +10 -0
- package/src/specs/get-spec-by-tag-name.spec.ts +68 -0
- package/src/specs/get-spec-by-tag-name.ts +16 -0
- package/src/specs/is-presentational.ts +6 -0
- package/src/specs/resolve-version.ts +20 -0
- package/src/{get-spec.spec.ts → specs/schema-to-spec.spec.ts} +2 -2
- package/src/{get-spec.ts → specs/schema-to-spec.ts} +22 -8
- package/src/types/aria.ts +147 -0
- package/src/{attributes.ts → types/attributes.ts} +5 -12
- package/src/{types.ts → types/index.ts} +70 -69
- package/src/{permitted-structres.ts → types/permitted-structres.ts} +15 -25
- package/src/{get-ns.ts → utils/get-ns.ts} +6 -1
- package/src/{utils.ts → utils/merge-array.ts} +0 -0
- package/src/utils/resolve-namespace.spec.ts +37 -0
- package/src/utils/resolve-namespace.ts +40 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/get-attr-specs.d.ts +0 -7
- package/lib/get-ns.d.ts +0 -1
- package/lib/get-spec-by-tag-name.d.ts +0 -2
- package/lib/get-spec-by-tag-name.js +0 -31
- package/schemas/wai-aria.schema.json +0 -87
- package/src/get-spec-by-tag-name.ts +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-spec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
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>",
|
|
@@ -16,16 +16,20 @@
|
|
|
16
16
|
"dev": "tsc --build --watch",
|
|
17
17
|
"clean": "tsc --build --clean",
|
|
18
18
|
"schema:gen": "ts-node ./gen/gen.ts; prettier --write './schemas/*.json';",
|
|
19
|
-
"schema:
|
|
20
|
-
"schema:attributes": "json2ts ./schemas/attributes.schema.json --cwd ./schemas > ./src/attributes.ts; prettier --write ./src/attributes.ts; eslint --fix --config ../../../.eslintrc ./src/attributes.ts",
|
|
21
|
-
"schema": "
|
|
19
|
+
"schema:content-models": "json2ts ./schemas/content-models.schema.json > ./src/types/permitted-structres.ts; prettier --write ./src/types/permitted-structres.ts; eslint --fix --config ../../../.eslintrc ./src/types/permitted-structres.ts",
|
|
20
|
+
"schema:attributes": "json2ts ./schemas/attributes.schema.json --cwd ./schemas > ./src/types/attributes.ts; prettier --write ./src/types/attributes.ts; eslint --fix --config ../../../.eslintrc ./src/types/attributes.ts",
|
|
21
|
+
"schema:aria": "json2ts ./schemas/aria.schema.json --cwd ./schemas > ./src/types/aria.ts; prettier --write ./src/types/aria.ts; eslint --fix --config ../../../.eslintrc ./src/types/aria.ts",
|
|
22
|
+
"schema": "run-s schema:*"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
25
|
+
"@markuplint/ml-ast": "3.0.0-alpha.0",
|
|
26
|
+
"dom-accessibility-api": "^0.5.14",
|
|
24
27
|
"tslib": "^2.3.1"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@markuplint/
|
|
30
|
+
"@markuplint/test-tools": "3.0.0-alpha.0",
|
|
31
|
+
"@markuplint/types": "3.0.0-alpha.0",
|
|
28
32
|
"json-schema-to-typescript": "^10.1.5"
|
|
29
33
|
},
|
|
30
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "d32c522e016888e20bcbb5f09352c006b964f193"
|
|
31
35
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
{
|
|
2
|
+
"definitions": {
|
|
3
|
+
"PermittedRoles": {
|
|
4
|
+
"description": "If `true`, this mean is \"Any\". If `false`, this mean is \"No\".",
|
|
5
|
+
"oneOf": [
|
|
6
|
+
{
|
|
7
|
+
"type": "boolean"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "array",
|
|
11
|
+
"items": {
|
|
12
|
+
"oneOf": [
|
|
13
|
+
{
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "object",
|
|
18
|
+
"required": ["name"],
|
|
19
|
+
"minProperties": 2,
|
|
20
|
+
"properties": {
|
|
21
|
+
"name": { "type": "string" },
|
|
22
|
+
"deprecated": { "type": "boolean", "enum": [true] }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "object",
|
|
30
|
+
"minProperties": 1,
|
|
31
|
+
"additionalProperties": false,
|
|
32
|
+
"properties": {
|
|
33
|
+
"core-aam": {
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"enum": [true]
|
|
36
|
+
},
|
|
37
|
+
"graphics-aam": {
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"enum": [true]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"PermittedARIAProperties": {
|
|
46
|
+
"description": "If set false:\n> No role or aria-* attributes",
|
|
47
|
+
"oneOf": [
|
|
48
|
+
{
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"enum": [false]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"type": "object",
|
|
54
|
+
"minProperties": 1,
|
|
55
|
+
"additionalProperties": false,
|
|
56
|
+
"properties": {
|
|
57
|
+
"global": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"enum": [true]
|
|
60
|
+
},
|
|
61
|
+
"role": {
|
|
62
|
+
"description": "Set true if the spec says \"and any aria-* attributes applicable to the allowed roles.\"",
|
|
63
|
+
"oneOf": [
|
|
64
|
+
{
|
|
65
|
+
"type": "boolean",
|
|
66
|
+
"enum": [true]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "string"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "array",
|
|
73
|
+
"minItems": 1,
|
|
74
|
+
"items": { "type": "string" }
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"only": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"minItems": 1,
|
|
81
|
+
"items": {
|
|
82
|
+
"oneOf": [
|
|
83
|
+
{
|
|
84
|
+
"type": "string",
|
|
85
|
+
"pattern": "^aria-.+"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "object",
|
|
89
|
+
"required": ["name"],
|
|
90
|
+
"additionalProperties": false,
|
|
91
|
+
"properties": {
|
|
92
|
+
"name": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"pattern": "^aria-.+"
|
|
95
|
+
},
|
|
96
|
+
"value": {
|
|
97
|
+
"type": "string"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"whithout": {
|
|
105
|
+
"type": "array",
|
|
106
|
+
"minItems": 1,
|
|
107
|
+
"items": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"required": ["type", "name"],
|
|
110
|
+
"additionalProperties": false,
|
|
111
|
+
"properties": {
|
|
112
|
+
"type": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"enum": ["not-recommended", "should-not", "must-not"]
|
|
115
|
+
},
|
|
116
|
+
"name": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"pattern": "^aria-.+"
|
|
119
|
+
},
|
|
120
|
+
"value": {
|
|
121
|
+
"type": "string"
|
|
122
|
+
},
|
|
123
|
+
"alt": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"required": ["method", "target"],
|
|
126
|
+
"additionalProperties": false,
|
|
127
|
+
"properties": {
|
|
128
|
+
"method": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"enum": ["remove-attr", "set-attr"]
|
|
131
|
+
},
|
|
132
|
+
"target": {
|
|
133
|
+
"type": "string"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"ImplicitRole": {
|
|
145
|
+
"description": "If `false`, this mean is \"No corresponding role\".",
|
|
146
|
+
"oneOf": [
|
|
147
|
+
{
|
|
148
|
+
"type": "boolean",
|
|
149
|
+
"enum": [false]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"type": "string"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"ImplicitProperties": {
|
|
157
|
+
"type": "object",
|
|
158
|
+
"minProperties": 1,
|
|
159
|
+
"patternProperties": {
|
|
160
|
+
"^aria-.+": {
|
|
161
|
+
"type": "string"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"ARIA": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"additionalProperties": false,
|
|
168
|
+
"required": ["implicitRole", "permittedRoles"],
|
|
169
|
+
"properties": {
|
|
170
|
+
"implicitRole": { "$ref": "#/definitions/ImplicitRole" },
|
|
171
|
+
"permittedRoles": { "$ref": "#/definitions/PermittedRoles" },
|
|
172
|
+
"namingProhibited": { "type": "boolean", "enum": [true] },
|
|
173
|
+
"implicitProperties": { "$ref": "#/definitions/ImplicitProperties" },
|
|
174
|
+
"properties": { "$ref": "#/definitions/PermittedARIAProperties" },
|
|
175
|
+
"conditions": {
|
|
176
|
+
"type": "object",
|
|
177
|
+
"minProperties": 1,
|
|
178
|
+
"patternProperties": {
|
|
179
|
+
".+": {
|
|
180
|
+
"type": "object",
|
|
181
|
+
"minProperties": 1,
|
|
182
|
+
"additionalProperties": false,
|
|
183
|
+
"properties": {
|
|
184
|
+
"implicitRole": { "$ref": "#/definitions/ImplicitRole" },
|
|
185
|
+
"permittedRoles": { "$ref": "#/definitions/PermittedRoles" },
|
|
186
|
+
"namingProhibited": { "type": "boolean", "enum": [true] },
|
|
187
|
+
"implicitProperties": { "$ref": "#/definitions/ImplicitProperties" },
|
|
188
|
+
"properties": { "$ref": "#/definitions/PermittedARIAProperties" }
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
"1.2": {
|
|
194
|
+
"type": "object",
|
|
195
|
+
"additionalProperties": false,
|
|
196
|
+
"minProperties": 1,
|
|
197
|
+
"properties": {
|
|
198
|
+
"implicitRole": { "$ref": "#/definitions/ImplicitRole" },
|
|
199
|
+
"permittedRoles": { "$ref": "#/definitions/PermittedRoles" },
|
|
200
|
+
"namingProhibited": { "type": "boolean", "enum": [true] },
|
|
201
|
+
"implicitProperties": { "$ref": "#/definitions/ImplicitProperties" },
|
|
202
|
+
"properties": { "$ref": "#/definitions/PermittedARIAProperties" },
|
|
203
|
+
"conditions": {
|
|
204
|
+
"type": "object",
|
|
205
|
+
"minProperties": 1,
|
|
206
|
+
"patternProperties": {
|
|
207
|
+
".+": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"minProperties": 1,
|
|
210
|
+
"additionalProperties": false,
|
|
211
|
+
"properties": {
|
|
212
|
+
"implicitRole": { "$ref": "#/definitions/ImplicitRole" },
|
|
213
|
+
"permittedRoles": { "$ref": "#/definitions/PermittedRoles" },
|
|
214
|
+
"namingProhibited": { "type": "boolean", "enum": [true] },
|
|
215
|
+
"implicitProperties": { "$ref": "#/definitions/ImplicitProperties" },
|
|
216
|
+
"properties": { "$ref": "#/definitions/PermittedARIAProperties" }
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"1.1": {
|
|
224
|
+
"type": "object",
|
|
225
|
+
"additionalProperties": false,
|
|
226
|
+
"minProperties": 1,
|
|
227
|
+
"properties": {
|
|
228
|
+
"implicitRole": { "$ref": "#/definitions/ImplicitRole" },
|
|
229
|
+
"permittedRoles": { "$ref": "#/definitions/PermittedRoles" },
|
|
230
|
+
"implicitProperties": { "$ref": "#/definitions/ImplicitProperties" },
|
|
231
|
+
"properties": { "$ref": "#/definitions/PermittedARIAProperties" },
|
|
232
|
+
"conditions": {
|
|
233
|
+
"type": "object",
|
|
234
|
+
"minProperties": 1,
|
|
235
|
+
"patternProperties": {
|
|
236
|
+
".+": {
|
|
237
|
+
"type": "object",
|
|
238
|
+
"minProperties": 1,
|
|
239
|
+
"additionalProperties": false,
|
|
240
|
+
"properties": {
|
|
241
|
+
"implicitRole": { "$ref": "#/definitions/ImplicitRole" },
|
|
242
|
+
"permittedRoles": { "$ref": "#/definitions/PermittedRoles" },
|
|
243
|
+
"implicitProperties": { "$ref": "#/definitions/ImplicitProperties" },
|
|
244
|
+
"properties": { "$ref": "#/definitions/PermittedARIAProperties" }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
"type": "object",
|
|
255
|
+
"properties": {
|
|
256
|
+
"_": { "$ref": "#/definitions/ARIA" }
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"definitions": {
|
|
3
3
|
"AttributeName": { "type": "string", "pattern": "^(?:(xml|xlink):)?[a-z][a-zA-Z0-9-]*$" },
|
|
4
|
-
"AttributeCondition": {
|
|
5
|
-
"oneOf": [
|
|
6
|
-
{
|
|
7
|
-
"type": "object",
|
|
8
|
-
"additionalProperties": false,
|
|
9
|
-
"required": ["ancestor"],
|
|
10
|
-
"properties": { "ancestor": { "$ref": "#/definitions/Selectors" } }
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"type": "object",
|
|
14
|
-
"additionalProperties": false,
|
|
15
|
-
"required": ["self"],
|
|
16
|
-
"properties": { "self": { "$ref": "#/definitions/Selectors" } }
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
4
|
+
"AttributeCondition": { "$ref": "#/definitions/Selectors" },
|
|
20
5
|
"Selectors": {
|
|
21
6
|
"oneOf": [{ "type": "string" }, { "type": "array", "minItems": 2, "items": { "type": "string" } }]
|
|
22
7
|
},
|
|
@@ -24,11 +9,8 @@
|
|
|
24
9
|
"AttributeJSON": {
|
|
25
10
|
"type": "object",
|
|
26
11
|
"additionalProperties": false,
|
|
27
|
-
"
|
|
28
|
-
"minProperties": 2,
|
|
12
|
+
"minProperties": 1,
|
|
29
13
|
"properties": {
|
|
30
|
-
"_TODO_": { "type": "string" },
|
|
31
|
-
"ref": { "type": "string", "format": "uri" },
|
|
32
14
|
"type": {
|
|
33
15
|
"oneOf": [
|
|
34
16
|
{ "$ref": "#/definitions/AttributeType" },
|
|
@@ -47,7 +29,8 @@
|
|
|
47
29
|
"noUse": { "type": "boolean" },
|
|
48
30
|
"condition": { "$ref": "#/definitions/AttributeCondition" },
|
|
49
31
|
"ineffective": { "$ref": "#/definitions/Selectors" },
|
|
50
|
-
"animatable": { "type": "boolean" }
|
|
32
|
+
"animatable": { "type": "boolean" },
|
|
33
|
+
"experimental": { "type": "boolean" }
|
|
51
34
|
}
|
|
52
35
|
},
|
|
53
36
|
"GlobalAttributes": {
|
|
@@ -212,10 +195,9 @@
|
|
|
212
195
|
},
|
|
213
196
|
"type": "object",
|
|
214
197
|
"additionalProperties": false,
|
|
215
|
-
"required": ["tag", "
|
|
198
|
+
"required": ["tag", "attributes"],
|
|
216
199
|
"properties": {
|
|
217
200
|
"tag": { "type": "string" },
|
|
218
|
-
"ref": { "type": "string", "format": "uri" },
|
|
219
201
|
"global": { "$ref": "#/definitions/GlobalAttributes" },
|
|
220
202
|
"attributes": { "$ref": "#/definitions/Attributes" }
|
|
221
203
|
}
|
|
@@ -1,33 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"definitions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
"description": "SVG Element",
|
|
17
|
-
"type": "string",
|
|
18
|
-
"pattern": "^svg:(?:[a-z][a-zA-Z0-9]*|[a-z][a-z0-9]*-[a-z][a-z0-9]*)$"
|
|
3
|
+
"ContentModel": {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["contents"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"contents": {
|
|
9
|
+
"oneOf": [
|
|
10
|
+
{
|
|
11
|
+
"$ref": "#/definitions/PermittedContentSpec"
|
|
12
|
+
},
|
|
13
|
+
{ "type": "boolean" }
|
|
14
|
+
]
|
|
19
15
|
},
|
|
16
|
+
"descendantOf": { "type": "string" },
|
|
17
|
+
"conditional": {
|
|
18
|
+
"type": "array",
|
|
19
|
+
"items": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"required": ["condition", "contents"],
|
|
23
|
+
"properties": {
|
|
24
|
+
"condition": {
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"contents": {
|
|
28
|
+
"oneOf": [
|
|
29
|
+
{
|
|
30
|
+
"$ref": "#/definitions/PermittedContentSpec"
|
|
31
|
+
},
|
|
32
|
+
{ "type": "boolean" }
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"ContentType": {
|
|
41
|
+
"oneOf": [
|
|
20
42
|
{
|
|
21
|
-
"description": "
|
|
43
|
+
"description": "Element",
|
|
22
44
|
"type": "string",
|
|
23
|
-
"
|
|
45
|
+
"pattern": "^[^#]+$"
|
|
24
46
|
},
|
|
25
|
-
{ "$ref": "#/definitions/
|
|
47
|
+
{ "$ref": "#/definitions/Category" }
|
|
26
48
|
]
|
|
27
49
|
},
|
|
28
|
-
"
|
|
50
|
+
"Category": {
|
|
29
51
|
"type": "string",
|
|
30
52
|
"enum": [
|
|
53
|
+
"#text",
|
|
31
54
|
"#phrasing",
|
|
32
55
|
"#flow",
|
|
33
56
|
"#interactive",
|
|
@@ -62,10 +85,10 @@
|
|
|
62
85
|
},
|
|
63
86
|
"Target": {
|
|
64
87
|
"oneOf": [
|
|
65
|
-
{ "$ref": "#/definitions/
|
|
88
|
+
{ "$ref": "#/definitions/ContentType" },
|
|
66
89
|
{
|
|
67
90
|
"type": "array",
|
|
68
|
-
"items": { "$ref": "#/definitions/
|
|
91
|
+
"items": { "$ref": "#/definitions/ContentType" },
|
|
69
92
|
"uniqueItems": true
|
|
70
93
|
}
|
|
71
94
|
]
|
|
@@ -94,7 +117,7 @@
|
|
|
94
117
|
"ignore": { "$ref": "#/definitions/Target" },
|
|
95
118
|
"notAllowedDescendants": {
|
|
96
119
|
"type": "array",
|
|
97
|
-
"items": { "$ref": "#/definitions/
|
|
120
|
+
"items": { "$ref": "#/definitions/ContentType" },
|
|
98
121
|
"uniqueItems": true
|
|
99
122
|
},
|
|
100
123
|
"max": { "type": "number" },
|
|
@@ -111,7 +134,7 @@
|
|
|
111
134
|
"ignore": { "$ref": "#/definitions/Target" },
|
|
112
135
|
"notAllowedDescendants": {
|
|
113
136
|
"type": "array",
|
|
114
|
-
"items": { "$ref": "#/definitions/
|
|
137
|
+
"items": { "$ref": "#/definitions/ContentType" },
|
|
115
138
|
"uniqueItems": true
|
|
116
139
|
},
|
|
117
140
|
"max": { "type": "number" },
|
|
@@ -129,7 +152,7 @@
|
|
|
129
152
|
"ignore": { "$ref": "#/definitions/Target" },
|
|
130
153
|
"notAllowedDescendants": {
|
|
131
154
|
"type": "array",
|
|
132
|
-
"items": { "$ref": "#/definitions/
|
|
155
|
+
"items": { "$ref": "#/definitions/ContentType" },
|
|
133
156
|
"uniqueItems": true
|
|
134
157
|
},
|
|
135
158
|
"max": { "type": "number" },
|
|
@@ -147,7 +170,7 @@
|
|
|
147
170
|
"ignore": { "$ref": "#/definitions/Target" },
|
|
148
171
|
"notAllowedDescendants": {
|
|
149
172
|
"type": "array",
|
|
150
|
-
"items": { "$ref": "#/definitions/
|
|
173
|
+
"items": { "$ref": "#/definitions/ContentType" },
|
|
151
174
|
"uniqueItems": true
|
|
152
175
|
},
|
|
153
176
|
"max": { "type": "number" },
|
|
@@ -184,61 +207,9 @@
|
|
|
184
207
|
},
|
|
185
208
|
"type": "object",
|
|
186
209
|
"additionalProperties": false,
|
|
187
|
-
"required": ["tag", "contents"],
|
|
188
210
|
"properties": {
|
|
189
|
-
"
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"type": "array",
|
|
193
|
-
"items": {
|
|
194
|
-
"type": "object",
|
|
195
|
-
"additionalProperties": false,
|
|
196
|
-
"required": ["condition", "contents"],
|
|
197
|
-
"properties": {
|
|
198
|
-
"condition": {
|
|
199
|
-
"type": "object",
|
|
200
|
-
"oneOf": [
|
|
201
|
-
{
|
|
202
|
-
"additionalProperties": false,
|
|
203
|
-
"required": ["hasAttr"],
|
|
204
|
-
"properties": {
|
|
205
|
-
"hasAttr": { "type": "string" }
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"additionalProperties": false,
|
|
210
|
-
"required": ["parent"],
|
|
211
|
-
"properties": {
|
|
212
|
-
"parent": { "type": "string" },
|
|
213
|
-
"hasNotAttr": {
|
|
214
|
-
"type": "string",
|
|
215
|
-
"description": "Not support yet"
|
|
216
|
-
},
|
|
217
|
-
"_TODO_": { "type": "string" },
|
|
218
|
-
"_parent": { "type": "string" }
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
]
|
|
222
|
-
},
|
|
223
|
-
"contents": {
|
|
224
|
-
"oneOf": [
|
|
225
|
-
{
|
|
226
|
-
"$ref": "#/definitions/PermittedContentSpec"
|
|
227
|
-
},
|
|
228
|
-
{ "type": "boolean" }
|
|
229
|
-
]
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
"contents": {
|
|
235
|
-
"oneOf": [
|
|
236
|
-
{
|
|
237
|
-
"$ref": "#/definitions/PermittedContentSpec"
|
|
238
|
-
},
|
|
239
|
-
{ "type": "boolean" }
|
|
240
|
-
]
|
|
241
|
-
},
|
|
242
|
-
"ancestor": { "$ref": "#/definitions/Node" }
|
|
211
|
+
"__contentModel": {
|
|
212
|
+
"$ref": "#/definitions/ContentModel"
|
|
213
|
+
}
|
|
243
214
|
}
|
|
244
215
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"additionalProperties": false,
|
|
4
|
+
"required": ["contentModel", "globalAttrs", "attributes", "aria"],
|
|
5
|
+
"properties": {
|
|
6
|
+
"contentModel": { "$ref": "./content-models.schema.json#/definitions/ContentModel" },
|
|
7
|
+
"globalAttrs": { "$ref": "./attributes.schema.json#/definitions/GlobalAttributes" },
|
|
8
|
+
"attributes": { "$ref": "./attributes.schema.json#/definitions/Attributes" },
|
|
9
|
+
"aria": { "$ref": "./aria.schema.json#/definitions/ARIA" }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"onabort",
|
|
66
66
|
"onauxclick",
|
|
67
67
|
"onbeforeinput",
|
|
68
|
+
"onbeforematch",
|
|
68
69
|
"onblur",
|
|
69
70
|
"oncancel",
|
|
70
71
|
"oncanplay",
|
|
@@ -154,7 +155,8 @@
|
|
|
154
155
|
"referrerpolicy",
|
|
155
156
|
"rel",
|
|
156
157
|
"target",
|
|
157
|
-
"type"
|
|
158
|
+
"type",
|
|
159
|
+
"fetchpriority"
|
|
158
160
|
]
|
|
159
161
|
},
|
|
160
162
|
"HTMLEmbededAndMediaContentAttrs": {
|
|
@@ -399,6 +401,7 @@
|
|
|
399
401
|
"onabort",
|
|
400
402
|
"onauxclick",
|
|
401
403
|
"onbeforeinput",
|
|
404
|
+
"onbeforematch",
|
|
402
405
|
"onblur",
|
|
403
406
|
"oncancel",
|
|
404
407
|
"oncanplay",
|
|
@@ -497,7 +500,8 @@
|
|
|
497
500
|
"referrerpolicy",
|
|
498
501
|
"rel",
|
|
499
502
|
"target",
|
|
500
|
-
"type"
|
|
503
|
+
"type",
|
|
504
|
+
"fetchpriority"
|
|
501
505
|
],
|
|
502
506
|
"propertyNames": { "$ref": "#/definitions/HTMLLinkAndFetchingAttrs" },
|
|
503
507
|
"patternProperties": { ".+": { "$ref": "./attributes.schema.json#/definitions/AttributeJSON" } }
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createJSDOMElement as c } from '@markuplint/test-tools';
|
|
2
|
+
|
|
3
|
+
import { getAccname } from './accname-computation';
|
|
4
|
+
|
|
5
|
+
test('Get accessible name', () => {
|
|
6
|
+
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
7
|
+
expect(getAccname(c('<div>text</div>'))).toBe('');
|
|
8
|
+
expect(getAccname(c('<div aria-label="label">text</div>'))).toBe('label');
|
|
9
|
+
expect(getAccname(c('<span aria-label="label">text</span>'))).toBe('label');
|
|
10
|
+
expect(getAccname(c('<img alt="alterative-text" />'))).toBe('alterative-text');
|
|
11
|
+
expect(getAccname(c('<img title="title" />'))).toBe('title');
|
|
12
|
+
expect(getAccname(c('<div><label for="a">label</label><input id="a" /></div>').children[1])).toBe('label');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Invisible element', () => {
|
|
16
|
+
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
17
|
+
expect(getAccname(c('<button aria-disabled="true">label</button>'))).toBe('label');
|
|
18
|
+
expect(getAccname(c('<button aria-hidden="true">label</button>'))).toBe('');
|
|
19
|
+
expect(getAccname(c('<button hidden>label</button>'))).toBe('');
|
|
20
|
+
expect(getAccname(c('<button style="display: none">label</button>'))).toBe('');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @see https://www.w3.org/TR/accname-1.1/#ex-1-example-1-element1-id-el1-aria-labelledby-el3-element2-id-el2-aria-labelledby-el1-element3-id-el3-hello-element3
|
|
25
|
+
*/
|
|
26
|
+
test('accname-1.1 Expample 1', () => {
|
|
27
|
+
const complex = c(`<div>
|
|
28
|
+
<input id="el1" aria-labelledby="el3" />
|
|
29
|
+
<input id="el2" aria-labelledby="el1" />
|
|
30
|
+
<h1 id="el3"> hello </h1>
|
|
31
|
+
</div>`);
|
|
32
|
+
expect(getAccname(complex.children[0])).toBe('hello');
|
|
33
|
+
expect(getAccname(complex.children[1])).toBe('');
|
|
34
|
+
expect(getAccname(complex.children[2])).toBe('hello');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* https://www.w3.org/TR/accname-1.1/#ex-2-example-2-h1-files-h1-ul-li-a-id-file_row1-href-files-documentation-pdf-documentation-pdf-a-span-role-button-tabindex-0-id-del_row1-aria-label-delete-aria-labelledby-del_row1-file_row1-span-li-li-a-id-file_row2-href-files-holidayletter-pdf-holidayletter-pdf-a-span-role-button-tabindex-0-id-del_row2-aria-label-delete-aria-labelledby-del_row2-file_row2-span-li-ul
|
|
39
|
+
*/
|
|
40
|
+
test('accname-1.1 Expample 2', () => {
|
|
41
|
+
const complex = c(`<ul>
|
|
42
|
+
<li>
|
|
43
|
+
<a id="file_row1" href="./files/Documentation.pdf">Documentation.pdf</a>
|
|
44
|
+
<span role="button" tabindex="0" id="del_row1" aria-label="Delete" aria-labelledby="del_row1 file_row1"></span>
|
|
45
|
+
</li>
|
|
46
|
+
<li>
|
|
47
|
+
<a id="file_row2" href="./files/HolidayLetter.pdf">HolidayLetter.pdf</a>
|
|
48
|
+
<span role="button" tabindex="0" id="del_row2" aria-label="Delete" aria-labelledby="del_row2 file_row2"></span>
|
|
49
|
+
</li>
|
|
50
|
+
</ul>`);
|
|
51
|
+
const spans = complex.querySelectorAll('span');
|
|
52
|
+
expect(getAccname(spans[0])).toBe('Delete Documentation.pdf');
|
|
53
|
+
expect(getAccname(spans[1])).toBe('Delete HolidayLetter.pdf');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* https://www.w3.org/TR/accname-1.1/#ex-3-example-3-div-role-checkbox-aria-checked-false-flash-the-screen-span-role-textbox-aria-multiline-false-5-span-times-div
|
|
58
|
+
*/
|
|
59
|
+
test('accname-1.1 Expample 3', () => {
|
|
60
|
+
const complex = c(
|
|
61
|
+
'<div role="checkbox" aria-checked="false">Flash the screen <span role="textbox" aria-multiline="false"> 5 </span> times</div>',
|
|
62
|
+
);
|
|
63
|
+
expect(getAccname(complex)).toBe('Flash the screen 5 times');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('with comment', () => {
|
|
67
|
+
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
68
|
+
expect(getAccname(c('<button>label<!-- comment --></button>'))).toBe('label');
|
|
69
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MLMLSpec } from '../types';
|
|
2
|
+
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
+
|
|
4
|
+
import { getAttrSpecs as _getAttrSpecs } from '../specs/get-attr-specs';
|
|
5
|
+
|
|
6
|
+
export function getAttrSpecs(el: Element, schema: MLMLSpec) {
|
|
7
|
+
return _getAttrSpecs(el.localName, el.namespaceURI as NamespaceURI, schema);
|
|
8
|
+
}
|