@markuplint/ml-spec 3.14.0 → 4.0.0-alpha.10
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/LICENSE +1 -1
- package/lib/constant/aria-version.d.ts +2 -2
- package/lib/constant/aria-version.js +2 -5
- package/lib/dom-traverse/accname-computation.js +4 -7
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
- package/lib/dom-traverse/get-attr-specs.js +3 -7
- package/lib/dom-traverse/get-computed-aria-props.d.ts +6 -6
- package/lib/dom-traverse/get-computed-aria-props.js +13 -18
- package/lib/dom-traverse/get-computed-role.d.ts +2 -7
- package/lib/dom-traverse/get-computed-role.js +33 -39
- package/lib/dom-traverse/get-content-model.d.ts +2 -27
- package/lib/dom-traverse/get-content-model.js +5 -10
- package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
- package/lib/dom-traverse/get-explicit-role.js +9 -14
- package/lib/dom-traverse/get-implicit-role.d.ts +2 -6
- package/lib/dom-traverse/get-implicit-role.js +8 -13
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +5 -11
- package/lib/dom-traverse/get-non-presentational-ancestor.js +5 -10
- package/lib/dom-traverse/get-permitted-roles.d.ts +4 -8
- package/lib/dom-traverse/get-permitted-roles.js +3 -7
- package/lib/dom-traverse/get-spec.d.ts +2 -5
- package/lib/dom-traverse/get-spec.js +3 -7
- package/lib/dom-traverse/has-required-owned-elements.d.ts +2 -8
- package/lib/dom-traverse/has-required-owned-elements.js +13 -20
- package/lib/dom-traverse/is-exposed.d.ts +1 -1
- package/lib/dom-traverse/is-exposed.js +17 -24
- package/lib/dom-traverse/matches-context-role.d.ts +2 -7
- package/lib/dom-traverse/matches-context-role.js +5 -9
- package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
- package/lib/dom-traverse/may-be-focusable.js +3 -7
- package/lib/index.d.ts +28 -28
- package/lib/index.js +28 -33
- package/lib/specs/aria-specs.d.ts +5 -8
- package/lib/specs/aria-specs.js +1 -5
- package/lib/specs/content-model-category-to-tag-names.d.ts +3 -6
- package/lib/specs/content-model-category-to-tag-names.js +1 -5
- package/lib/specs/get-aria.d.ts +3 -9
- package/lib/specs/get-aria.js +11 -17
- package/lib/specs/get-attr-specs.d.ts +4 -8
- package/lib/specs/get-attr-specs.js +6 -11
- package/lib/specs/get-implicit-role.d.ts +2 -8
- package/lib/specs/get-implicit-role.js +3 -7
- package/lib/specs/get-permitted-roles.d.ts +4 -10
- package/lib/specs/get-permitted-roles.js +14 -17
- package/lib/specs/get-role-spec.d.ts +4 -11
- package/lib/specs/get-role-spec.js +10 -14
- package/lib/specs/get-selectors-by-content-model-category.d.ts +2 -2
- package/lib/specs/get-selectors-by-content-model-category.js +2 -6
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -6
- package/lib/specs/get-spec-by-tag-name.js +4 -9
- package/lib/specs/is-nothing-content-model.js +3 -7
- package/lib/specs/is-palpable-elements.d.ts +5 -9
- package/lib/specs/is-palpable-elements.js +5 -10
- package/lib/specs/is-presentational.js +1 -5
- package/lib/specs/is-void-element.d.ts +3 -1
- package/lib/specs/is-void-element.js +4 -10
- package/lib/specs/resolve-version.d.ts +3 -6
- package/lib/specs/resolve-version.js +7 -12
- package/lib/specs/schema-to-spec.d.ts +4 -4
- package/lib/specs/schema-to-spec.js +20 -25
- package/lib/types/aria.d.ts +133 -147
- package/lib/types/aria.js +1 -2
- package/lib/types/attributes.d.ts +110 -1504
- package/lib/types/attributes.js +1 -2
- package/lib/types/index.d.ts +149 -177
- package/lib/types/index.js +1 -2
- package/lib/types/permitted-structures.d.ts +35 -74
- package/lib/types/permitted-structures.js +1 -2
- package/lib/utils/get-ns.js +1 -5
- package/lib/utils/merge-array.d.ts +4 -9
- package/lib/utils/merge-array.js +2 -6
- package/lib/utils/resolve-namespace.d.ts +4 -4
- package/lib/utils/resolve-namespace.js +4 -9
- package/lib/utils/{validateAriaVersion.d.ts → validate-aria-version.d.ts} +1 -1
- package/lib/utils/validate-aria-version.js +4 -0
- package/package.json +20 -14
- package/lib/utils/validateAriaVersion.js +0 -8
- package/test/dom-traverse/accname-computation.spec.js +0 -69
- package/test/dom-traverse/get-computed-aria-props.spec.js +0 -758
- package/test/dom-traverse/get-computed-role.spec.js +0 -315
- package/test/dom-traverse/get-implicit-role.spec.js +0 -40
- package/test/dom-traverse/has-required-owned-elements.spec.js +0 -34
- package/test/dom-traverse/is-exposed.spec.js +0 -70
- package/test/dom-traverse/matches-context-role.spec.js +0 -60
- package/test/specs/get-attr-specs.spec.js +0 -41
- package/test/specs/get-implicit-role.spec.js +0 -79
- package/test/specs/get-permitted-roles.spec.js +0 -418
- package/test/specs/get-role-spec.spec.js +0 -67
- package/test/specs/get-spec-by-tag-name.spec.js +0 -68
- package/test/specs/resolve-version.spec.js +0 -34
- package/test/specs/schema-to-spec.spec.js +0 -61
- package/test/utils/resolve-namespace.spec.js +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
1
|
+
import type { ARIAVersion, Matches, MLMLSpec } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Getting permitted ARIA roles.
|
|
4
4
|
*
|
|
@@ -6,13 +6,7 @@ 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
|
-
|
|
12
|
-
namespace: string | null,
|
|
13
|
-
version: ARIAVersion,
|
|
14
|
-
matches: Matches,
|
|
15
|
-
): readonly {
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly deprecated?: boolean;
|
|
9
|
+
export declare function getPermittedRoles(specs: MLMLSpec, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): readonly {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly deprecated?: boolean;
|
|
18
12
|
}[];
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const aria_specs_1 = require("./aria-specs");
|
|
7
|
-
const get_aria_1 = require("./get-aria");
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { isPlainObject } from 'is-plain-object';
|
|
3
|
+
import { mergeArray } from '../utils/merge-array.js';
|
|
4
|
+
import { ariaSpecs } from './aria-specs.js';
|
|
5
|
+
import { getARIA } from './get-aria.js';
|
|
8
6
|
/**
|
|
9
7
|
* Getting permitted ARIA roles.
|
|
10
8
|
*
|
|
@@ -12,16 +10,16 @@ const get_aria_1 = require("./get-aria");
|
|
|
12
10
|
* - If `true`, this mean is "Any".
|
|
13
11
|
* - If `false`, this mean is "No".
|
|
14
12
|
*/
|
|
15
|
-
function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
16
|
-
const aria =
|
|
13
|
+
export function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
14
|
+
const aria = getARIA(specs, localName, namespace, version, matches);
|
|
17
15
|
if (!aria) {
|
|
18
16
|
return [];
|
|
19
17
|
}
|
|
20
18
|
const { implicitRole, permittedRoles } = aria;
|
|
21
|
-
const { roles, graphicsRoles } =
|
|
19
|
+
const { roles, graphicsRoles } = ariaSpecs(specs, version);
|
|
22
20
|
let permittedRoleList = [];
|
|
23
21
|
if (permittedRoles === true) {
|
|
24
|
-
permittedRoleList =
|
|
22
|
+
permittedRoleList = mergeArray(permittedRoleList, roles
|
|
25
23
|
.filter(role => !role.isAbstract)
|
|
26
24
|
.map(role => ({
|
|
27
25
|
name: role.name,
|
|
@@ -29,14 +27,14 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
29
27
|
}
|
|
30
28
|
if (isAAMInfo(permittedRoles)) {
|
|
31
29
|
if (permittedRoles['core-aam']) {
|
|
32
|
-
permittedRoleList =
|
|
30
|
+
permittedRoleList = mergeArray(permittedRoleList, roles
|
|
33
31
|
.filter(role => !role.isAbstract)
|
|
34
32
|
.map(role => ({
|
|
35
33
|
name: role.name,
|
|
36
34
|
})));
|
|
37
35
|
}
|
|
38
36
|
if (permittedRoles['graphics-aam']) {
|
|
39
|
-
permittedRoleList =
|
|
37
|
+
permittedRoleList = mergeArray(permittedRoleList, graphicsRoles
|
|
40
38
|
.filter(role => !role.isAbstract)
|
|
41
39
|
.map(role => ({
|
|
42
40
|
name: role.name,
|
|
@@ -44,7 +42,7 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
else if (typeof permittedRoles !== 'boolean') {
|
|
47
|
-
permittedRoleList =
|
|
45
|
+
permittedRoleList = mergeArray(permittedRoleList, permittedRoles.map(role => {
|
|
48
46
|
if (typeof role === 'string') {
|
|
49
47
|
return {
|
|
50
48
|
name: role,
|
|
@@ -57,9 +55,8 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
57
55
|
return permittedRoleList;
|
|
58
56
|
}
|
|
59
57
|
const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
|
|
60
|
-
return
|
|
58
|
+
return mergeArray(implicitRoles.map(r => ({ name: r })), permittedRoleList);
|
|
61
59
|
}
|
|
62
|
-
exports.getPermittedRoles = getPermittedRoles;
|
|
63
60
|
function isAAMInfo(permittedRoles) {
|
|
64
|
-
return
|
|
61
|
+
return isPlainObject(permittedRoles);
|
|
65
62
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types';
|
|
1
|
+
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types/index.js';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getRoleSpec(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
namespace: NamespaceURI,
|
|
7
|
-
version: ARIAVersion,
|
|
8
|
-
):
|
|
9
|
-
| (ARIARole & {
|
|
10
|
-
superClassRoles: ARIARoleInSchema[];
|
|
11
|
-
})
|
|
12
|
-
| null;
|
|
3
|
+
export declare function getRoleSpec(specs: MLMLSpec, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
|
|
4
|
+
superClassRoles: ARIARoleInSchema[];
|
|
5
|
+
}) | null;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getRoleSpec = void 0;
|
|
4
|
-
const aria_specs_1 = require("./aria-specs");
|
|
5
|
-
function getRoleSpec(specs, roleName, namespace, version) {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
1
|
+
import { ariaSpecs } from './aria-specs.js';
|
|
2
|
+
export function getRoleSpec(specs, roleName, namespace, version) {
|
|
7
3
|
const role = getRoleByName(specs, roleName, namespace, version);
|
|
8
4
|
if (!role) {
|
|
9
5
|
return null;
|
|
@@ -12,19 +8,18 @@ function getRoleSpec(specs, roleName, namespace, version) {
|
|
|
12
8
|
return {
|
|
13
9
|
name: role.name,
|
|
14
10
|
isAbstract: !!role.isAbstract,
|
|
15
|
-
requiredContextRole:
|
|
16
|
-
requiredOwnedElements:
|
|
11
|
+
requiredContextRole: role.requiredContextRole ?? [],
|
|
12
|
+
requiredOwnedElements: role.requiredOwnedElements ?? [],
|
|
17
13
|
accessibleNameRequired: !!role.accessibleNameRequired,
|
|
18
14
|
accessibleNameFromAuthor: !!role.accessibleNameFromAuthor,
|
|
19
15
|
accessibleNameFromContent: !!role.accessibleNameFromContent,
|
|
20
16
|
accessibleNameProhibited: !!role.accessibleNameProhibited,
|
|
21
17
|
childrenPresentational: !!role.childrenPresentational,
|
|
22
|
-
ownedProperties:
|
|
23
|
-
prohibitedProperties:
|
|
18
|
+
ownedProperties: role.ownedProperties ?? [],
|
|
19
|
+
prohibitedProperties: role.prohibitedProperties ?? [],
|
|
24
20
|
superClassRoles,
|
|
25
21
|
};
|
|
26
22
|
}
|
|
27
|
-
exports.getRoleSpec = getRoleSpec;
|
|
28
23
|
function recursiveTraverseSuperClassRoles(specs, roleName, namespace, version) {
|
|
29
24
|
const roles = [];
|
|
30
25
|
const superClassRoles = getSuperClassRoles(specs, roleName, namespace, version);
|
|
@@ -38,12 +33,13 @@ function recursiveTraverseSuperClassRoles(specs, roleName, namespace, version) {
|
|
|
38
33
|
return roles;
|
|
39
34
|
}
|
|
40
35
|
function getSuperClassRoles(specs, roleName, namespace, version) {
|
|
41
|
-
var _a, _b;
|
|
42
36
|
const role = getRoleByName(specs, roleName, namespace, version);
|
|
43
|
-
return (
|
|
37
|
+
return (role?.generalization
|
|
38
|
+
?.map(roleName => getRoleByName(specs, roleName, namespace, version))
|
|
39
|
+
.filter((role) => !!role) ?? null);
|
|
44
40
|
}
|
|
45
41
|
function getRoleByName(specs, roleName, namespace, version) {
|
|
46
|
-
const { roles, graphicsRoles } =
|
|
42
|
+
const { roles, graphicsRoles } = ariaSpecs(specs, version);
|
|
47
43
|
let role = roles.find(r => r.name === roleName);
|
|
48
44
|
if (!role && namespace === 'http://www.w3.org/2000/svg') {
|
|
49
45
|
role = graphicsRoles.find(r => r.name === roleName);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
2
|
-
import type { Category } from '../types/permitted-structures';
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
import type { Category } from '../types/permitted-structures.js';
|
|
3
3
|
export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSelectorsByContentModelCategory = void 0;
|
|
4
|
-
function getSelectorsByContentModelCategory(specs, category) {
|
|
1
|
+
export function getSelectorsByContentModelCategory(specs, category) {
|
|
5
2
|
const selectors = specs.def['#contentModels'][category];
|
|
6
|
-
return selectors
|
|
3
|
+
return selectors ?? [];
|
|
7
4
|
}
|
|
8
|
-
exports.getSelectorsByContentModelCategory = getSelectorsByContentModelCategory;
|
|
@@ -1,6 +1,2 @@
|
|
|
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;
|
|
1
|
+
import type { ElementSpec } from '../types/index.js';
|
|
2
|
+
export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(specs: readonly Pick<ElementSpec, 'name' | K>[], localName: string, namespace: string | null): Pick<ElementSpec, "name" | K> | null;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSpecByTagName = void 0;
|
|
4
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
1
|
+
import { resolveNamespace } from '../utils/resolve-namespace.js';
|
|
5
2
|
const cache = new Map();
|
|
6
|
-
function getSpecByTagName(specs, localName, namespace) {
|
|
7
|
-
|
|
8
|
-
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace !== null && namespace !== void 0 ? namespace : undefined);
|
|
3
|
+
export function getSpecByTagName(specs, localName, namespace) {
|
|
4
|
+
const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined);
|
|
9
5
|
let spec = cache.get(localNameWithNS);
|
|
10
6
|
if (spec !== undefined) {
|
|
11
7
|
return spec;
|
|
12
8
|
}
|
|
13
|
-
spec =
|
|
9
|
+
spec = specs.find(spec => spec.name === localNameWithNS) ?? null;
|
|
14
10
|
cache.set(localNameWithNS, spec);
|
|
15
11
|
return spec;
|
|
16
12
|
}
|
|
17
|
-
exports.getSpecByTagName = getSpecByTagName;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNothingContentModel = void 0;
|
|
4
|
-
const is_void_element_1 = require("./is-void-element");
|
|
1
|
+
import { isVoidElement } from './is-void-element.js';
|
|
5
2
|
/**
|
|
6
3
|
* @see https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
|
|
7
4
|
* @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
|
8
5
|
*/
|
|
9
|
-
function isNothingContentModel(
|
|
6
|
+
export function isNothingContentModel(
|
|
10
7
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
11
8
|
el) {
|
|
12
|
-
return
|
|
9
|
+
return isVoidElement(el) || ['iframe', 'template'].includes(el.localName);
|
|
13
10
|
}
|
|
14
|
-
exports.isNothingContentModel = isNothingContentModel;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function isPalpableElement(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly extendsSvg?: boolean;
|
|
7
|
-
readonly extendsExposableElements?: boolean;
|
|
8
|
-
},
|
|
9
|
-
): boolean;
|
|
1
|
+
import type { MLMLSpec } from '../types/index.js';
|
|
2
|
+
export declare function isPalpableElement(el: Element, specs: MLMLSpec, options?: {
|
|
3
|
+
readonly extendsSvg?: boolean;
|
|
4
|
+
readonly extendsExposableElements?: boolean;
|
|
5
|
+
}): boolean;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPalpableElement = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Exposable content models and elements
|
|
6
3
|
*
|
|
@@ -31,19 +28,17 @@ const exposableElementsThatAreNoBelongingAModel = [
|
|
|
31
28
|
'thead',
|
|
32
29
|
'tr',
|
|
33
30
|
];
|
|
34
|
-
function isPalpableElement(
|
|
31
|
+
export function isPalpableElement(
|
|
35
32
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
36
33
|
el, specs, options) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
conditions.push((_d = (_c = specs.def['#contentModels']['#SVGRenderable']) === null || _c === void 0 ? void 0 : _c.join(',')) !== null && _d !== void 0 ? _d : '');
|
|
34
|
+
const conditions = [specs.def['#contentModels']['#palpable']?.join(',') ?? ''];
|
|
35
|
+
if (options?.extendsSvg !== false /* default true */) {
|
|
36
|
+
conditions.push(specs.def['#contentModels']['#SVGRenderable']?.join(',') ?? '');
|
|
41
37
|
}
|
|
42
|
-
if (options
|
|
38
|
+
if (options?.extendsExposableElements /* default false */) {
|
|
43
39
|
conditions.push(exposableElementsThatAreNoBelongingAModel.join(','));
|
|
44
40
|
}
|
|
45
41
|
return conditions.some(condition => {
|
|
46
42
|
return el.matches(condition);
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
|
-
exports.isPalpableElement = isPalpableElement;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPresentational = void 0;
|
|
4
|
-
function isPresentational(roleName) {
|
|
1
|
+
export function isPresentational(roleName) {
|
|
5
2
|
if (!roleName) {
|
|
6
3
|
return false;
|
|
7
4
|
}
|
|
8
5
|
return ['presentation', 'none'].includes(roleName);
|
|
9
6
|
}
|
|
10
|
-
exports.isPresentational = isPresentational;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isVoidElement = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @see https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
6
3
|
*/
|
|
7
|
-
const voidElements = [
|
|
4
|
+
const voidElements = new Set([
|
|
8
5
|
'area',
|
|
9
6
|
'base',
|
|
10
7
|
'br',
|
|
@@ -18,10 +15,7 @@ const voidElements = [
|
|
|
18
15
|
'source',
|
|
19
16
|
'track',
|
|
20
17
|
'wbr',
|
|
21
|
-
];
|
|
22
|
-
function isVoidElement(
|
|
23
|
-
|
|
24
|
-
el) {
|
|
25
|
-
return voidElements.includes(el.localName);
|
|
18
|
+
]);
|
|
19
|
+
export function isVoidElement(el) {
|
|
20
|
+
return voidElements.has(el.localName);
|
|
26
21
|
}
|
|
27
|
-
exports.isVoidElement = isVoidElement;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ARIA } from '../types/aria.js';
|
|
2
|
+
import type { ARIAVersion } from '../types/index.js';
|
|
3
3
|
import type { ReadonlyDeep } from 'type-fest';
|
|
4
|
-
export declare function resolveVersion(
|
|
5
|
-
aria: ReadonlyDeep<ARIA>,
|
|
6
|
-
version: ARIAVersion,
|
|
7
|
-
): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
|
|
4
|
+
export declare function resolveVersion(aria: ReadonlyDeep<ARIA>, version: ARIAVersion): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const implicitProperties = (_f = (_e = aria[version]) === null || _e === void 0 ? void 0 : _e.implicitProperties) !== null && _f !== void 0 ? _f : aria.implicitProperties;
|
|
9
|
-
const properties = (_h = (_g = aria[version]) === null || _g === void 0 ? void 0 : _g.properties) !== null && _h !== void 0 ? _h : aria.properties;
|
|
10
|
-
const namingProhibited = version === '1.1' ? aria.namingProhibited : (_k = (_j = aria[version]) === null || _j === void 0 ? void 0 : _j.namingProhibited) !== null && _k !== void 0 ? _k : aria.namingProhibited;
|
|
11
|
-
const conditions = (_m = (_l = aria[version]) === null || _l === void 0 ? void 0 : _l.conditions) !== null && _m !== void 0 ? _m : aria.conditions;
|
|
1
|
+
export function resolveVersion(aria, version) {
|
|
2
|
+
const implicitRole = aria[version]?.implicitRole ?? aria.implicitRole;
|
|
3
|
+
const permittedRoles = aria[version]?.permittedRoles ?? aria.permittedRoles;
|
|
4
|
+
const implicitProperties = aria[version]?.implicitProperties ?? aria.implicitProperties;
|
|
5
|
+
const properties = aria[version]?.properties ?? aria.properties;
|
|
6
|
+
const namingProhibited = version === '1.1' ? aria.namingProhibited : aria[version]?.namingProhibited ?? aria.namingProhibited;
|
|
7
|
+
const conditions = aria[version]?.conditions ?? aria.conditions;
|
|
12
8
|
return {
|
|
13
9
|
implicitRole,
|
|
14
10
|
permittedRoles,
|
|
@@ -18,4 +14,3 @@ function resolveVersion(aria, version) {
|
|
|
18
14
|
conditions,
|
|
19
15
|
};
|
|
20
16
|
}
|
|
21
|
-
exports.resolveVersion = resolveVersion;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementSpec, ExtendedSpec, MLMLSpec } from '../types';
|
|
1
|
+
import type { ElementSpec, ExtendedSpec, MLMLSpec } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Merging HTML-spec schema and extended spec schemas
|
|
4
4
|
*
|
|
@@ -7,7 +7,7 @@ import type { ElementSpec, ExtendedSpec, MLMLSpec } from '../types';
|
|
|
7
7
|
* @param schemas `MLDocument.schemas`
|
|
8
8
|
*/
|
|
9
9
|
export declare function schemaToSpec(schemas: readonly [MLMLSpec, ...ExtendedSpec[]]): {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
cites: import("../types/index.js").Cites;
|
|
11
|
+
def: import("../types/index.js").SpecDefs;
|
|
12
|
+
specs: readonly ElementSpec[];
|
|
13
13
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.schemaToSpec = void 0;
|
|
4
|
-
const merge_array_1 = require("../utils/merge-array");
|
|
1
|
+
import { mergeArray } from '../utils/merge-array.js';
|
|
5
2
|
/**
|
|
6
3
|
* Merging HTML-spec schema and extended spec schemas
|
|
7
4
|
*
|
|
@@ -9,8 +6,7 @@ const merge_array_1 = require("../utils/merge-array");
|
|
|
9
6
|
*
|
|
10
7
|
* @param schemas `MLDocument.schemas`
|
|
11
8
|
*/
|
|
12
|
-
function schemaToSpec(schemas) {
|
|
13
|
-
var _a, _b, _c, _d, _e;
|
|
9
|
+
export function schemaToSpec(schemas) {
|
|
14
10
|
const [main, ...extendedSpecs] = schemas;
|
|
15
11
|
const result = { ...main };
|
|
16
12
|
for (const extendedSpec of extendedSpecs) {
|
|
@@ -19,30 +15,30 @@ function schemaToSpec(schemas) {
|
|
|
19
15
|
}
|
|
20
16
|
if (extendedSpec.def) {
|
|
21
17
|
const def = { ...result.def };
|
|
22
|
-
if (
|
|
18
|
+
if (extendedSpec.def['#globalAttrs']?.['#extends']) {
|
|
23
19
|
const gAttrs = { ...def['#globalAttrs'] };
|
|
24
20
|
gAttrs['#HTMLGlobalAttrs'] = {
|
|
25
|
-
...
|
|
26
|
-
...
|
|
21
|
+
...def['#globalAttrs']?.['#HTMLGlobalAttrs'],
|
|
22
|
+
...extendedSpec.def['#globalAttrs']?.['#extends'],
|
|
27
23
|
};
|
|
28
24
|
def['#globalAttrs'] = gAttrs;
|
|
29
25
|
}
|
|
30
26
|
if (extendedSpec.def['#aria']) {
|
|
31
27
|
def['#aria'] = {
|
|
32
28
|
'1.1': {
|
|
33
|
-
roles:
|
|
34
|
-
props:
|
|
35
|
-
graphicsRoles:
|
|
29
|
+
roles: mergeArray(def['#aria']['1.1'].roles, extendedSpec.def['#aria']['1.1'].roles),
|
|
30
|
+
props: mergeArray(def['#aria']['1.1'].props, extendedSpec.def['#aria']['1.1'].props),
|
|
31
|
+
graphicsRoles: mergeArray(def['#aria']['1.1'].graphicsRoles, extendedSpec.def['#aria']['1.1'].graphicsRoles),
|
|
36
32
|
},
|
|
37
33
|
'1.2': {
|
|
38
|
-
roles:
|
|
39
|
-
props:
|
|
40
|
-
graphicsRoles:
|
|
34
|
+
roles: mergeArray(def['#aria']['1.2'].roles, extendedSpec.def['#aria']['1.2'].roles),
|
|
35
|
+
props: mergeArray(def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
|
|
36
|
+
graphicsRoles: mergeArray(def['#aria']['1.2'].graphicsRoles, extendedSpec.def['#aria']['1.2'].graphicsRoles),
|
|
41
37
|
},
|
|
42
38
|
'1.3': {
|
|
43
|
-
roles:
|
|
44
|
-
props:
|
|
45
|
-
graphicsRoles:
|
|
39
|
+
roles: mergeArray(def['#aria']['1.3'].roles, extendedSpec.def['#aria']['1.3'].roles),
|
|
40
|
+
props: mergeArray(def['#aria']['1.3'].props, extendedSpec.def['#aria']['1.3'].props),
|
|
41
|
+
graphicsRoles: mergeArray(def['#aria']['1.3'].graphicsRoles, extendedSpec.def['#aria']['1.3'].graphicsRoles),
|
|
46
42
|
},
|
|
47
43
|
};
|
|
48
44
|
}
|
|
@@ -55,14 +51,14 @@ function schemaToSpec(schemas) {
|
|
|
55
51
|
for (const modelName of keys) {
|
|
56
52
|
const mainModel = def['#contentModels'][modelName];
|
|
57
53
|
const exModel = extendedSpec.def['#contentModels'][modelName];
|
|
58
|
-
models[modelName] = [...(mainModel
|
|
54
|
+
models[modelName] = [...(mainModel ?? []), ...(exModel ?? [])];
|
|
59
55
|
}
|
|
60
56
|
def['#contentModels'] = models;
|
|
61
57
|
}
|
|
62
58
|
result.def = def;
|
|
63
59
|
}
|
|
64
60
|
if (extendedSpec.specs) {
|
|
65
|
-
const exSpecs = extendedSpec.specs
|
|
61
|
+
const exSpecs = [...extendedSpec.specs];
|
|
66
62
|
const specs = [];
|
|
67
63
|
for (const elSpec of result.specs) {
|
|
68
64
|
const tagName = elSpec.name.toLowerCase();
|
|
@@ -77,10 +73,10 @@ function schemaToSpec(schemas) {
|
|
|
77
73
|
...exSpec,
|
|
78
74
|
globalAttrs: {
|
|
79
75
|
...elSpec.globalAttrs,
|
|
80
|
-
...exSpec
|
|
76
|
+
...exSpec?.globalAttrs,
|
|
81
77
|
},
|
|
82
|
-
attributes: mergeAttrSpec(elSpec.attributes, exSpec
|
|
83
|
-
categories:
|
|
78
|
+
attributes: mergeAttrSpec(elSpec.attributes, exSpec?.attributes),
|
|
79
|
+
categories: mergeArray(elSpec.categories, exSpec?.categories),
|
|
84
80
|
});
|
|
85
81
|
}
|
|
86
82
|
result.specs = specs;
|
|
@@ -88,10 +84,9 @@ function schemaToSpec(schemas) {
|
|
|
88
84
|
}
|
|
89
85
|
return result;
|
|
90
86
|
}
|
|
91
|
-
exports.schemaToSpec = schemaToSpec;
|
|
92
87
|
function mergeAttrSpec(std, ex = {}) {
|
|
93
88
|
const result = {};
|
|
94
|
-
const keys =
|
|
89
|
+
const keys = [...new Set([...Object.keys(std), ...Object.keys(ex)])];
|
|
95
90
|
for (const key of keys) {
|
|
96
91
|
const _std = std[key];
|
|
97
92
|
const _ex = ex[key];
|