@markuplint/ml-spec 3.0.0-alpha.0 → 3.0.0-alpha.2
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-content-model.d.ts +3 -0
- package/lib/dom-traverse/get-content-model.js +28 -0
- package/lib/dom-traverse/get-spec.d.ts +2 -2
- package/lib/dom-traverse/get-spec.js +2 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
- package/lib/specs/content-model-category-to-tag-names.js +2 -2
- package/lib/specs/get-aria.js +3 -3
- package/lib/specs/get-attr-specs.d.ts +1 -1
- package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -1
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -2
- package/lib/specs/get-spec-by-tag-name.js +1 -1
- package/lib/specs/schema-to-spec.d.ts +1 -1
- package/lib/specs/schema-to-spec.js +1 -1
- package/lib/types/aria.d.ts +7 -1
- package/lib/types/attributes.d.ts +93 -38
- package/lib/types/index.d.ts +8 -8
- package/lib/types/permitted-structres.d.ts +21 -27
- package/lib/types/permitted-structures.d.ts +54 -0
- package/lib/types/permitted-structures.js +8 -0
- package/package.json +7 -7
- package/schema.json +6 -6
- package/schemas/aria.schema.json +1 -1
- package/schemas/content-models.schema.json +32 -47
- package/src/dom-traverse/accname-computation.spec.ts +3 -3
- package/src/dom-traverse/get-computed-role.spec.ts +1 -1
- package/src/dom-traverse/get-content-model.ts +32 -0
- package/src/dom-traverse/get-spec.ts +3 -3
- package/src/index.ts +2 -1
- package/src/specs/content-model-category-to-tag-names.ts +3 -3
- package/src/specs/get-aria.ts +3 -3
- package/src/specs/get-selectors-by-content-model-category.ts +1 -1
- package/src/specs/get-spec-by-tag-name.spec.ts +10 -10
- package/src/specs/get-spec-by-tag-name.ts +9 -5
- package/src/specs/schema-to-spec.ts +1 -1
- package/src/types/aria.ts +7 -1
- package/src/types/attributes.ts +160 -105
- package/src/types/index.ts +8 -8
- package/src/types/permitted-structres.ts +23 -30
- package/src/types/permitted-structures.ts +97 -0
- package/tsconfig.tsbuildinfo +1 -1
- 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/utils/cache.d.ts +0 -10
- package/lib/utils/cache.js +0 -42
- package/lib/utils.d.ts +0 -8
- package/lib/utils.js +0 -50
package/lib/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ARIA } from './aria';
|
|
2
2
|
import type { AttributeJSON, AttributeType, GlobalAttributes } from './attributes';
|
|
3
|
-
import type { ContentModel, Category } from './permitted-
|
|
3
|
+
import type { ContentModel, Category } from './permitted-structures';
|
|
4
4
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* markuplint Markup-language spec
|
|
7
7
|
*/
|
|
8
8
|
export interface MLMLSpec {
|
|
9
9
|
cites: Cites;
|
|
@@ -82,7 +82,7 @@ export declare type ElementSpec = {
|
|
|
82
82
|
*/
|
|
83
83
|
nonStandard?: true;
|
|
84
84
|
/**
|
|
85
|
-
* Element
|
|
85
|
+
* Element categories
|
|
86
86
|
*/
|
|
87
87
|
categories: Category[];
|
|
88
88
|
/**
|
|
@@ -90,9 +90,9 @@ export declare type ElementSpec = {
|
|
|
90
90
|
*/
|
|
91
91
|
contentModel: ContentModel;
|
|
92
92
|
/**
|
|
93
|
-
* Tag
|
|
93
|
+
* Tag omission
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
omission: ElementSpecOmission;
|
|
96
96
|
/**
|
|
97
97
|
* Global Attributes
|
|
98
98
|
*/
|
|
@@ -102,7 +102,7 @@ export declare type ElementSpec = {
|
|
|
102
102
|
*/
|
|
103
103
|
attributes: Record<string, Attribute>;
|
|
104
104
|
/**
|
|
105
|
-
* WAI-ARIA role and
|
|
105
|
+
* WAI-ARIA role and properties
|
|
106
106
|
*/
|
|
107
107
|
aria: ARIA;
|
|
108
108
|
/**
|
|
@@ -115,8 +115,8 @@ export declare type ElementSpec = {
|
|
|
115
115
|
*/
|
|
116
116
|
possibleToAddProperties?: true;
|
|
117
117
|
};
|
|
118
|
-
declare type
|
|
119
|
-
declare type
|
|
118
|
+
declare type ElementSpecOmission = false | ElementSpecOmissionTags;
|
|
119
|
+
declare type ElementSpecOmissionTags = {
|
|
120
120
|
startTag: boolean | ElementCondition;
|
|
121
121
|
endTag: boolean | ElementCondition;
|
|
122
122
|
};
|
|
@@ -3,62 +3,56 @@
|
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
4
|
* and run json-schema-to-typescript to regenerate this file.
|
|
5
5
|
*/
|
|
6
|
-
export declare type
|
|
7
|
-
export declare type
|
|
6
|
+
export declare type PermittedContentPattern = PermittedContentRequire | PermittedContentOptional | PermittedContentOneOrMore | PermittedContentZeroOrMore | PermittedContentChoice | PermittedContentTransparent;
|
|
7
|
+
export declare type Model = ContentType | ContentType[];
|
|
8
8
|
export declare type ContentType = string | Category;
|
|
9
|
-
export declare type Category = '#text' | '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#
|
|
10
|
-
export declare type PermittedContentSpec = PermittedContent[];
|
|
9
|
+
export declare type Category = '#text' | '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#embedded' | '#palpable' | '#script-supporting' | '#SVGAnimation' | '#SVGBasicShapes' | '#SVGContainer' | '#SVGDescriptive' | '#SVGFilterPrimitive' | '#SVGFont' | '#SVGGradient' | '#SVGGraphics' | '#SVGGraphicsReferencing' | '#SVGLightSource' | '#SVGNeverRendered' | '#SVGNone' | '#SVGPaintServer' | '#SVGRenderable' | '#SVGShape' | '#SVGStructural' | '#SVGStructurallyExternal' | '#SVGTextContent' | '#SVGTextContentChild' | '#SVGOtherXMLNamespace';
|
|
11
10
|
export interface ContentModelsSchema {
|
|
12
11
|
__contentModel?: ContentModel;
|
|
13
12
|
}
|
|
14
13
|
export interface ContentModel {
|
|
15
|
-
contents:
|
|
14
|
+
contents: PermittedContentPattern[] | boolean;
|
|
16
15
|
descendantOf?: string;
|
|
17
16
|
conditional?: {
|
|
18
17
|
condition: string;
|
|
19
|
-
contents:
|
|
18
|
+
contents: PermittedContentPattern[] | boolean;
|
|
20
19
|
}[];
|
|
21
20
|
}
|
|
22
21
|
export interface PermittedContentRequire {
|
|
23
|
-
require:
|
|
24
|
-
ignore?: Target;
|
|
25
|
-
notAllowedDescendants?: ContentType[];
|
|
22
|
+
require: Model;
|
|
26
23
|
max?: number;
|
|
27
24
|
min?: number;
|
|
28
25
|
_TODO_?: string;
|
|
29
26
|
}
|
|
30
27
|
export interface PermittedContentOptional {
|
|
31
|
-
optional:
|
|
32
|
-
ignore?: Target;
|
|
33
|
-
notAllowedDescendants?: ContentType[];
|
|
28
|
+
optional: Model;
|
|
34
29
|
max?: number;
|
|
35
30
|
_TODO_?: string;
|
|
36
31
|
}
|
|
37
32
|
export interface PermittedContentOneOrMore {
|
|
38
|
-
oneOrMore:
|
|
39
|
-
ignore?: Target;
|
|
40
|
-
notAllowedDescendants?: ContentType[];
|
|
33
|
+
oneOrMore: Model | PermittedContentPattern[];
|
|
41
34
|
max?: number;
|
|
42
35
|
_TODO_?: string;
|
|
43
36
|
}
|
|
44
37
|
export interface PermittedContentZeroOrMore {
|
|
45
|
-
zeroOrMore:
|
|
46
|
-
ignore?: Target;
|
|
47
|
-
notAllowedDescendants?: ContentType[];
|
|
38
|
+
zeroOrMore: Model | PermittedContentPattern[];
|
|
48
39
|
max?: number;
|
|
49
40
|
_TODO_?: string;
|
|
50
41
|
}
|
|
51
42
|
export interface PermittedContentChoice {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @minItems 2
|
|
45
|
+
* @maxItems 5
|
|
46
|
+
*/
|
|
47
|
+
choice: [PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [
|
|
48
|
+
PermittedContentPattern[],
|
|
49
|
+
PermittedContentPattern[],
|
|
50
|
+
PermittedContentPattern[],
|
|
51
|
+
PermittedContentPattern[],
|
|
52
|
+
PermittedContentPattern[]
|
|
58
53
|
];
|
|
59
54
|
_TODO_?: string;
|
|
60
55
|
}
|
|
61
|
-
export interface
|
|
62
|
-
|
|
63
|
-
_TODO_?: string;
|
|
56
|
+
export interface PermittedContentTransparent {
|
|
57
|
+
transparent: string;
|
|
64
58
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
+
*/
|
|
6
|
+
export declare type PermittedContentPattern = PermittedContentRequire | PermittedContentOptional | PermittedContentOneOrMore | PermittedContentZeroOrMore | PermittedContentChoice | PermittedContentTransparent;
|
|
7
|
+
export declare type Model = ContentType | ContentType[];
|
|
8
|
+
export declare type ContentType = string | Category;
|
|
9
|
+
export declare type Category = '#text' | '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#embedded' | '#palpable' | '#script-supporting' | '#SVGAnimation' | '#SVGBasicShapes' | '#SVGContainer' | '#SVGDescriptive' | '#SVGFilterPrimitive' | '#SVGFont' | '#SVGGradient' | '#SVGGraphics' | '#SVGGraphicsReferencing' | '#SVGLightSource' | '#SVGNeverRendered' | '#SVGNone' | '#SVGPaintServer' | '#SVGRenderable' | '#SVGShape' | '#SVGStructural' | '#SVGStructurallyExternal' | '#SVGTextContent' | '#SVGTextContentChild' | '#SVGOtherXMLNamespace';
|
|
10
|
+
export interface ContentModelsSchema {
|
|
11
|
+
__contentModel?: ContentModel;
|
|
12
|
+
}
|
|
13
|
+
export interface ContentModel {
|
|
14
|
+
contents: PermittedContentPattern[] | boolean;
|
|
15
|
+
descendantOf?: string;
|
|
16
|
+
conditional?: {
|
|
17
|
+
condition: string;
|
|
18
|
+
contents: PermittedContentPattern[] | boolean;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
export interface PermittedContentRequire {
|
|
22
|
+
require: Model;
|
|
23
|
+
max?: number;
|
|
24
|
+
min?: number;
|
|
25
|
+
_TODO_?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PermittedContentOptional {
|
|
28
|
+
optional: Model;
|
|
29
|
+
max?: number;
|
|
30
|
+
_TODO_?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface PermittedContentOneOrMore {
|
|
33
|
+
oneOrMore: Model | PermittedContentPattern[];
|
|
34
|
+
max?: number;
|
|
35
|
+
_TODO_?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PermittedContentZeroOrMore {
|
|
38
|
+
zeroOrMore: Model | PermittedContentPattern[];
|
|
39
|
+
max?: number;
|
|
40
|
+
_TODO_?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface PermittedContentChoice {
|
|
43
|
+
choice: [PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [
|
|
44
|
+
PermittedContentPattern[],
|
|
45
|
+
PermittedContentPattern[],
|
|
46
|
+
PermittedContentPattern[],
|
|
47
|
+
PermittedContentPattern[],
|
|
48
|
+
PermittedContentPattern[]
|
|
49
|
+
];
|
|
50
|
+
_TODO_?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface PermittedContentTransparent {
|
|
53
|
+
transparent: string;
|
|
54
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/**
|
|
4
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
5
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
6
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-spec",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
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>",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"schema": "run-s schema:*"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@markuplint/ml-ast": "3.0.0-alpha.
|
|
25
|
+
"@markuplint/ml-ast": "3.0.0-alpha.2",
|
|
26
26
|
"dom-accessibility-api": "^0.5.14",
|
|
27
|
-
"tslib": "^2.
|
|
27
|
+
"tslib": "^2.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@markuplint/test-tools": "3.0.0-alpha.
|
|
31
|
-
"@markuplint/types": "3.0.0-alpha.
|
|
32
|
-
"json-schema-to-typescript": "^
|
|
30
|
+
"@markuplint/test-tools": "3.0.0-alpha.2",
|
|
31
|
+
"@markuplint/types": "3.0.0-alpha.2",
|
|
32
|
+
"json-schema-to-typescript": "^11.0.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "830bf8187b81bf5ca2f5f09b6f85a98395a58bdb"
|
|
35
35
|
}
|
package/schema.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"type": "string"
|
|
19
19
|
},
|
|
20
|
-
"
|
|
20
|
+
"AttributeCategory": {
|
|
21
21
|
"enum": ["aria", "eventhandler", "form", "global", "particular", "xml"],
|
|
22
22
|
"type": "string"
|
|
23
23
|
},
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"items": {
|
|
86
86
|
"properties": {
|
|
87
87
|
"category": {
|
|
88
|
-
"$ref": "#/definitions/
|
|
88
|
+
"$ref": "#/definitions/AttributeCategory"
|
|
89
89
|
},
|
|
90
90
|
"deprecated": {
|
|
91
91
|
"enum": [true],
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
{
|
|
163
163
|
"properties": {
|
|
164
164
|
"category": {
|
|
165
|
-
"$ref": "#/definitions/
|
|
165
|
+
"$ref": "#/definitions/AttributeCategory"
|
|
166
166
|
},
|
|
167
167
|
"deprecated": {
|
|
168
168
|
"enum": [true],
|
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
"type": "array"
|
|
212
212
|
},
|
|
213
213
|
"categories": {
|
|
214
|
-
"description": "Element
|
|
214
|
+
"description": "Element categories",
|
|
215
215
|
"items": {
|
|
216
216
|
"anyOf": [
|
|
217
217
|
{
|
|
@@ -294,7 +294,7 @@
|
|
|
294
294
|
],
|
|
295
295
|
"description": "Obsolete or alternative elements"
|
|
296
296
|
},
|
|
297
|
-
"
|
|
297
|
+
"omission": {
|
|
298
298
|
"anyOf": [
|
|
299
299
|
{
|
|
300
300
|
"properties": {
|
|
@@ -338,7 +338,7 @@
|
|
|
338
338
|
"type": "boolean"
|
|
339
339
|
}
|
|
340
340
|
],
|
|
341
|
-
"description": "Tag
|
|
341
|
+
"description": "Tag omission"
|
|
342
342
|
},
|
|
343
343
|
"permittedContent": {
|
|
344
344
|
"description": "Permitted content",
|
package/schemas/aria.schema.json
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"contents": {
|
|
9
9
|
"oneOf": [
|
|
10
10
|
{
|
|
11
|
-
"
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": { "$ref": "#/definitions/PermittedContentPattern" }
|
|
12
13
|
},
|
|
13
14
|
{ "type": "boolean" }
|
|
14
15
|
]
|
|
@@ -27,7 +28,8 @@
|
|
|
27
28
|
"contents": {
|
|
28
29
|
"oneOf": [
|
|
29
30
|
{
|
|
30
|
-
"
|
|
31
|
+
"type": "array",
|
|
32
|
+
"items": { "$ref": "#/definitions/PermittedContentPattern" }
|
|
31
33
|
},
|
|
32
34
|
{ "type": "boolean" }
|
|
33
35
|
]
|
|
@@ -57,7 +59,6 @@
|
|
|
57
59
|
"#heading",
|
|
58
60
|
"#sectioning",
|
|
59
61
|
"#metadata",
|
|
60
|
-
"#transparent",
|
|
61
62
|
"#embedded",
|
|
62
63
|
"#palpable",
|
|
63
64
|
"#script-supporting",
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
"#SVGOtherXMLNamespace"
|
|
84
85
|
]
|
|
85
86
|
},
|
|
86
|
-
"
|
|
87
|
+
"Model": {
|
|
87
88
|
"oneOf": [
|
|
88
89
|
{ "$ref": "#/definitions/ContentType" },
|
|
89
90
|
{
|
|
@@ -93,11 +94,7 @@
|
|
|
93
94
|
}
|
|
94
95
|
]
|
|
95
96
|
},
|
|
96
|
-
"
|
|
97
|
-
"type": "array",
|
|
98
|
-
"items": { "$ref": "#/definitions/PermittedContent" }
|
|
99
|
-
},
|
|
100
|
-
"PermittedContent": {
|
|
97
|
+
"PermittedContentPattern": {
|
|
101
98
|
"type": "object",
|
|
102
99
|
"oneOf": [
|
|
103
100
|
{ "$ref": "#/definitions/PermittedContentRequire" },
|
|
@@ -105,7 +102,7 @@
|
|
|
105
102
|
{ "$ref": "#/definitions/PermittedContentOneOrMore" },
|
|
106
103
|
{ "$ref": "#/definitions/PermittedContentZeroOrMore" },
|
|
107
104
|
{ "$ref": "#/definitions/PermittedContentChoice" },
|
|
108
|
-
{ "$ref": "#/definitions/
|
|
105
|
+
{ "$ref": "#/definitions/PermittedContentTransparent" }
|
|
109
106
|
]
|
|
110
107
|
},
|
|
111
108
|
"PermittedContentRequire": {
|
|
@@ -113,13 +110,7 @@
|
|
|
113
110
|
"additionalProperties": false,
|
|
114
111
|
"required": ["require"],
|
|
115
112
|
"properties": {
|
|
116
|
-
"require": { "$ref": "#/definitions/
|
|
117
|
-
"ignore": { "$ref": "#/definitions/Target" },
|
|
118
|
-
"notAllowedDescendants": {
|
|
119
|
-
"type": "array",
|
|
120
|
-
"items": { "$ref": "#/definitions/ContentType" },
|
|
121
|
-
"uniqueItems": true
|
|
122
|
-
},
|
|
113
|
+
"require": { "$ref": "#/definitions/Model" },
|
|
123
114
|
"max": { "type": "number" },
|
|
124
115
|
"min": { "type": "number" },
|
|
125
116
|
"_TODO_": { "type": "string" }
|
|
@@ -130,13 +121,7 @@
|
|
|
130
121
|
"additionalProperties": false,
|
|
131
122
|
"required": ["optional"],
|
|
132
123
|
"properties": {
|
|
133
|
-
"optional": { "$ref": "#/definitions/
|
|
134
|
-
"ignore": { "$ref": "#/definitions/Target" },
|
|
135
|
-
"notAllowedDescendants": {
|
|
136
|
-
"type": "array",
|
|
137
|
-
"items": { "$ref": "#/definitions/ContentType" },
|
|
138
|
-
"uniqueItems": true
|
|
139
|
-
},
|
|
124
|
+
"optional": { "$ref": "#/definitions/Model" },
|
|
140
125
|
"max": { "type": "number" },
|
|
141
126
|
"_TODO_": { "type": "string" }
|
|
142
127
|
}
|
|
@@ -147,13 +132,13 @@
|
|
|
147
132
|
"required": ["oneOrMore"],
|
|
148
133
|
"properties": {
|
|
149
134
|
"oneOrMore": {
|
|
150
|
-
"oneOf": [
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
135
|
+
"oneOf": [
|
|
136
|
+
{ "$ref": "#/definitions/Model" },
|
|
137
|
+
{
|
|
138
|
+
"type": "array",
|
|
139
|
+
"items": { "$ref": "#/definitions/PermittedContentPattern" }
|
|
140
|
+
}
|
|
141
|
+
]
|
|
157
142
|
},
|
|
158
143
|
"max": { "type": "number" },
|
|
159
144
|
"_TODO_": { "type": "string" }
|
|
@@ -165,13 +150,13 @@
|
|
|
165
150
|
"required": ["zeroOrMore"],
|
|
166
151
|
"properties": {
|
|
167
152
|
"zeroOrMore": {
|
|
168
|
-
"oneOf": [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
153
|
+
"oneOf": [
|
|
154
|
+
{ "$ref": "#/definitions/Model" },
|
|
155
|
+
{
|
|
156
|
+
"type": "array",
|
|
157
|
+
"items": { "$ref": "#/definitions/PermittedContentPattern" }
|
|
158
|
+
}
|
|
159
|
+
]
|
|
175
160
|
},
|
|
176
161
|
"max": { "type": "number" },
|
|
177
162
|
"_TODO_": { "type": "string" }
|
|
@@ -184,24 +169,24 @@
|
|
|
184
169
|
"properties": {
|
|
185
170
|
"choice": {
|
|
186
171
|
"type": "array",
|
|
187
|
-
"items": {
|
|
172
|
+
"items": {
|
|
173
|
+
"type": "array",
|
|
174
|
+
"items": { "$ref": "#/definitions/PermittedContentPattern" }
|
|
175
|
+
},
|
|
188
176
|
"minItems": 2,
|
|
189
177
|
"maxItems": 5
|
|
190
178
|
},
|
|
191
179
|
"_TODO_": { "type": "string" }
|
|
192
180
|
}
|
|
193
181
|
},
|
|
194
|
-
"
|
|
182
|
+
"PermittedContentTransparent": {
|
|
195
183
|
"type": "object",
|
|
196
184
|
"additionalProperties": false,
|
|
197
|
-
"required": ["
|
|
185
|
+
"required": ["transparent"],
|
|
198
186
|
"properties": {
|
|
199
|
-
"
|
|
200
|
-
"type": "
|
|
201
|
-
|
|
202
|
-
"minItems": 2
|
|
203
|
-
},
|
|
204
|
-
"_TODO_": { "type": "string" }
|
|
187
|
+
"transparent": {
|
|
188
|
+
"type": "string"
|
|
189
|
+
}
|
|
205
190
|
}
|
|
206
191
|
}
|
|
207
192
|
},
|
|
@@ -23,7 +23,7 @@ test('Invisible element', () => {
|
|
|
23
23
|
/**
|
|
24
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
25
|
*/
|
|
26
|
-
test('accname-1.1
|
|
26
|
+
test('accname-1.1 Example 1', () => {
|
|
27
27
|
const complex = c(`<div>
|
|
28
28
|
<input id="el1" aria-labelledby="el3" />
|
|
29
29
|
<input id="el2" aria-labelledby="el1" />
|
|
@@ -37,7 +37,7 @@ test('accname-1.1 Expample 1', () => {
|
|
|
37
37
|
/**
|
|
38
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
39
|
*/
|
|
40
|
-
test('accname-1.1
|
|
40
|
+
test('accname-1.1 Example 2', () => {
|
|
41
41
|
const complex = c(`<ul>
|
|
42
42
|
<li>
|
|
43
43
|
<a id="file_row1" href="./files/Documentation.pdf">Documentation.pdf</a>
|
|
@@ -56,7 +56,7 @@ test('accname-1.1 Expample 2', () => {
|
|
|
56
56
|
/**
|
|
57
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
58
|
*/
|
|
59
|
-
test('accname-1.1
|
|
59
|
+
test('accname-1.1 Example 3', () => {
|
|
60
60
|
const complex = c(
|
|
61
61
|
'<div role="checkbox" aria-checked="false">Flash the screen <span role="textbox" aria-multiline="false"> 5 </span> times</div>',
|
|
62
62
|
);
|
|
@@ -93,7 +93,7 @@ describe('getComputedRole', () => {
|
|
|
93
93
|
expect(c('<div hidden><span tabindex="0" role="none"></span></div>', '1.2', 'span').role?.name).toBe('none');
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
test('Presentational Roles Conflict Resolution (2-1) Required
|
|
96
|
+
test('Presentational Roles Conflict Resolution (2-1) Required Owned Elements', () => {
|
|
97
97
|
expect(c('<table><tr><td>foo</td></tr></table>', '1.2', 'td').role?.name).toBe('cell');
|
|
98
98
|
expect(c('<table><tr><td role="none">foo</td></tr></table>', '1.2', 'td').role?.name).toBe('cell');
|
|
99
99
|
expect(c('<table><tbody role="none"><tr><td>foo</td></tr></tbody></table>', '1.2', 'tbody').role?.name).toBe(
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ElementSpec } from '../types';
|
|
2
|
+
import type { PermittedContentPattern } from '../types/permitted-structures';
|
|
3
|
+
|
|
4
|
+
import { getSpec } from './get-spec';
|
|
5
|
+
|
|
6
|
+
type Specs = Pick<ElementSpec, 'name' | 'contentModel'>[];
|
|
7
|
+
|
|
8
|
+
const cachesBySpecs = new Map<Specs, Map<Element, PermittedContentPattern[] | boolean | null>>();
|
|
9
|
+
export function getContentModel(el: Element, specs: Pick<ElementSpec, 'name' | 'contentModel'>[]) {
|
|
10
|
+
const cacheByEl = cachesBySpecs.get(specs) ?? new Map<Element, PermittedContentPattern[] | boolean>();
|
|
11
|
+
const cached = cacheByEl.get(el);
|
|
12
|
+
if (cached) {
|
|
13
|
+
return cached;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const spec = getSpec<'contentModel'>(el, specs);
|
|
17
|
+
if (!spec) {
|
|
18
|
+
cacheByEl.set(el, null);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const conditions = spec.contentModel.conditional ?? [];
|
|
23
|
+
for (const cond of conditions) {
|
|
24
|
+
if (el.matches(cond.condition)) {
|
|
25
|
+
cacheByEl.set(el, cond.contents);
|
|
26
|
+
return cond.contents;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
cacheByEl.set(el, spec.contentModel.contents);
|
|
31
|
+
return spec.contentModel.contents;
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ElementSpec } from '../types';
|
|
2
2
|
|
|
3
3
|
import { getSpecByTagName } from '../specs/get-spec-by-tag-name';
|
|
4
4
|
|
|
5
|
-
export function getSpec(el: Element,
|
|
6
|
-
return getSpecByTagName(
|
|
5
|
+
export function getSpec<K extends keyof ElementSpec>(el: Element, specs: Pick<ElementSpec, 'name' | K>[]) {
|
|
6
|
+
return getSpecByTagName(specs, el.localName, el.namespaceURI);
|
|
7
7
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './dom-traverse/accname-computation';
|
|
2
2
|
export * from './dom-traverse/get-attr-specs';
|
|
3
3
|
export * from './dom-traverse/get-computed-role';
|
|
4
|
+
export * from './dom-traverse/get-content-model';
|
|
4
5
|
export * from './dom-traverse/get-implicit-role';
|
|
5
6
|
export * from './dom-traverse/get-permitted-roles';
|
|
6
7
|
export * from './dom-traverse/get-spec';
|
|
@@ -14,5 +15,5 @@ export * from './specs/schema-to-spec';
|
|
|
14
15
|
export * from './types';
|
|
15
16
|
export * from './types/aria';
|
|
16
17
|
export * from './types/attributes';
|
|
17
|
-
export * from './types/permitted-
|
|
18
|
+
export * from './types/permitted-structures';
|
|
18
19
|
export * from './utils/resolve-namespace';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
import type { Category } from '../types/permitted-
|
|
2
|
+
import type { Category } from '../types/permitted-structures';
|
|
3
3
|
|
|
4
4
|
const cache = new Map<Category, ReadonlyArray<string>>();
|
|
5
5
|
|
|
6
|
-
export function contentModelCategoryToTagNames(contentModel: Category,
|
|
6
|
+
export function contentModelCategoryToTagNames(contentModel: Category, def: MLMLSpec['def']): ReadonlyArray<string> {
|
|
7
7
|
const cached = cache.get(contentModel);
|
|
8
8
|
if (cached) {
|
|
9
9
|
return cached;
|
|
10
10
|
}
|
|
11
|
-
const tags: string[] | undefined =
|
|
11
|
+
const tags: string[] | undefined = def['#contentModels'][contentModel];
|
|
12
12
|
const sortedTag = Object.freeze(tags && Array.isArray(tags) ? tags.sort() : []);
|
|
13
13
|
cache.set(contentModel, sortedTag);
|
|
14
14
|
return sortedTag;
|
package/src/specs/get-aria.ts
CHANGED
|
@@ -21,9 +21,9 @@ export function getARIA(
|
|
|
21
21
|
if (!conditions) {
|
|
22
22
|
return aria;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const conditionKeys = Object.keys(conditions);
|
|
25
25
|
let { implicitRole, permittedRoles, implicitProperties, properties, namingProhibited } = aria;
|
|
26
|
-
for (const cond of
|
|
26
|
+
for (const cond of conditionKeys) {
|
|
27
27
|
if (!matches(cond)) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
@@ -54,7 +54,7 @@ function getVersionResolvedARIA(
|
|
|
54
54
|
if (aria !== undefined) {
|
|
55
55
|
return aria;
|
|
56
56
|
}
|
|
57
|
-
const spec = getSpecByTagName(specs, localName, namespace)?.aria;
|
|
57
|
+
const spec = getSpecByTagName(specs.specs, localName, namespace)?.aria;
|
|
58
58
|
if (!spec) {
|
|
59
59
|
cache.set(key, null);
|
|
60
60
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import specs from '@markuplint/html-spec';
|
|
1
|
+
import { specs } from '@markuplint/html-spec';
|
|
2
2
|
|
|
3
3
|
import { getSpecByTagName } from './get-spec-by-tag-name';
|
|
4
4
|
|
|
@@ -8,26 +8,26 @@ const divSpec = {
|
|
|
8
8
|
condition: 'dl > div',
|
|
9
9
|
contents: [
|
|
10
10
|
{
|
|
11
|
-
zeroOrMore: '
|
|
11
|
+
zeroOrMore: ':model(script-supporting)',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
oneOrMore: 'dt',
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
zeroOrMore: '
|
|
17
|
+
zeroOrMore: ':model(script-supporting)',
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
oneOrMore: 'dd',
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
zeroOrMore: '
|
|
23
|
+
zeroOrMore: ':model(script-supporting)',
|
|
24
24
|
},
|
|
25
25
|
],
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
28
|
contents: [
|
|
29
29
|
{
|
|
30
|
-
|
|
30
|
+
oneOrMore: ':model(flow)',
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
33
|
};
|
|
@@ -43,11 +43,11 @@ test('svg:svg', () => {
|
|
|
43
43
|
contents: [
|
|
44
44
|
{
|
|
45
45
|
zeroOrMore: [
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
46
|
+
':model(SVGAnimation)',
|
|
47
|
+
':model(SVGDescriptive)',
|
|
48
|
+
':model(SVGPaintServer)',
|
|
49
|
+
':model(SVGShape)',
|
|
50
|
+
':model(SVGStructural)',
|
|
51
51
|
'svg|a',
|
|
52
52
|
'svg|clipPath',
|
|
53
53
|
'svg|filter',
|