@markuplint/ml-spec 3.5.0 → 3.6.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/get-attr-specs.d.ts +1 -1
- package/lib/dom-traverse/get-computed-aria-props.d.ts +5 -5
- package/lib/dom-traverse/get-computed-aria-props.js +1 -1
- package/lib/dom-traverse/get-computed-role.js +5 -5
- package/lib/dom-traverse/get-content-model.d.ts +26 -1
- package/lib/dom-traverse/get-content-model.js +1 -1
- package/lib/dom-traverse/get-explicit-role.js +2 -1
- package/lib/dom-traverse/get-implicit-role.d.ts +5 -1
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +10 -4
- package/lib/dom-traverse/get-spec.d.ts +4 -1
- package/lib/dom-traverse/has-required-owned-elements.d.ts +7 -1
- package/lib/dom-traverse/is-exposed.js +3 -2
- 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.js +1 -1
- 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.js +4 -4
- 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.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-palpable-elements.d.ts +8 -4
- package/lib/specs/is-palpable-elements.js +3 -3
- package/lib/specs/resolve-version.d.ts +4 -1
- package/lib/specs/schema-to-spec.d.ts +3 -3
- package/lib/types/aria.d.ts +127 -113
- package/lib/types/attributes.d.ts +1490 -110
- package/lib/types/index.d.ts +172 -144
- package/lib/types/permitted-structures.d.ts +74 -35
- package/lib/utils/merge-array.d.ts +9 -4
- package/lib/utils/resolve-namespace.d.ts +4 -4
- package/lib/utils/resolve-namespace.js +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import(
|
|
2
|
+
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): readonly import('../types').Attribute[] | null;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
2
|
type ARIAProps = Record<string, ARIAProp>;
|
|
3
3
|
type ARIAProp = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
name: string;
|
|
5
|
+
value: string | undefined;
|
|
6
|
+
required: boolean;
|
|
7
|
+
deprecated: boolean;
|
|
8
|
+
from: ARIAPropReferenceType;
|
|
9
9
|
};
|
|
10
10
|
type ARIAPropReferenceType = 'default' | 'html-attr' | 'aria-attr';
|
|
11
11
|
export declare function getComputedAriaProps(specs: MLMLSpec, el: Element, version: ARIAVersion): ARIAProps;
|
|
@@ -90,7 +90,7 @@ function isValidAriaValue(spec, role, value, enumList) {
|
|
|
90
90
|
}
|
|
91
91
|
case 'token':
|
|
92
92
|
case 'token list': {
|
|
93
|
-
if (
|
|
93
|
+
if (enumList.length === 0) {
|
|
94
94
|
throw new Error('Need an enum list in token and token list types');
|
|
95
95
|
}
|
|
96
96
|
return enumList.includes(value.toLowerCase());
|
|
@@ -12,7 +12,7 @@ const may_be_focusable_1 = require("./may-be-focusable");
|
|
|
12
12
|
function getComputedRole(specs,
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
14
14
|
el, version) {
|
|
15
|
-
var _a, _b, _c
|
|
15
|
+
var _a, _b, _c;
|
|
16
16
|
const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, el, version);
|
|
17
17
|
const explicitRole = (0, get_explicit_role_1.getExplicitRole)(specs, el, version);
|
|
18
18
|
const computedRole = explicitRole.role ? explicitRole : implicitRole;
|
|
@@ -41,7 +41,7 @@ el, version) {
|
|
|
41
41
|
* However, the presentational role behaves transparently
|
|
42
42
|
* according to the sample code in WAI-ARIA specification.
|
|
43
43
|
*/
|
|
44
|
-
if (
|
|
44
|
+
if (computedRole.role && computedRole.role.requiredContextRole.length > 0) {
|
|
45
45
|
const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
|
|
46
46
|
if (!nonPresentationalAncestor.role) {
|
|
47
47
|
return {
|
|
@@ -50,7 +50,7 @@ el, version) {
|
|
|
50
50
|
errorType: 'NO_OWNER',
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
if (!((
|
|
53
|
+
if (!((_a = computedRole.role) === null || _a === void 0 ? void 0 : _a.requiredContextRole.includes(nonPresentationalAncestor.role.name))) {
|
|
54
54
|
return {
|
|
55
55
|
el,
|
|
56
56
|
role: null,
|
|
@@ -113,7 +113,7 @@ el, version) {
|
|
|
113
113
|
*/
|
|
114
114
|
if (explicitRole.role) {
|
|
115
115
|
const nonPresentationalAncestor = (0, get_non_presentational_ancestor_1.getNonPresentationalAncestor)(el, specs, version);
|
|
116
|
-
if ((
|
|
116
|
+
if (nonPresentationalAncestor.role && ((_b = nonPresentationalAncestor.role) === null || _b === void 0 ? void 0 : _b.requiredOwnedElements.length) > 0) {
|
|
117
117
|
if (nonPresentationalAncestor.role.requiredOwnedElements.some(expected => {
|
|
118
118
|
// const ancestor = nonPresentationalAncestor.el;
|
|
119
119
|
// const ancestorImplicitRole = getImplicitRole(specs, ancestor, version);
|
|
@@ -139,7 +139,7 @@ el, version) {
|
|
|
139
139
|
*/
|
|
140
140
|
const { props } = (0, aria_specs_1.ariaSpecs)(specs, version);
|
|
141
141
|
for (const attr of Array.from(el.attributes)) {
|
|
142
|
-
if ((
|
|
142
|
+
if ((_c = props.find(p => p.name === attr.name)) === null || _c === void 0 ? void 0 : _c.isGlobal) {
|
|
143
143
|
return {
|
|
144
144
|
...implicitRole,
|
|
145
145
|
errorType: 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL',
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
2
|
type Specs = readonly Pick<ElementSpec, 'name' | 'contentModel'>[];
|
|
3
|
-
export declare function getContentModel(
|
|
3
|
+
export declare function getContentModel(
|
|
4
|
+
el: Element,
|
|
5
|
+
specs: Specs,
|
|
6
|
+
):
|
|
7
|
+
| boolean
|
|
8
|
+
| readonly (
|
|
9
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
10
|
+
import('../types/permitted-structures').PermittedContentRequire
|
|
11
|
+
>
|
|
12
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
13
|
+
import('../types/permitted-structures').PermittedContentOptional
|
|
14
|
+
>
|
|
15
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
16
|
+
import('../types/permitted-structures').PermittedContentOneOrMore
|
|
17
|
+
>
|
|
18
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
19
|
+
import('../types/permitted-structures').PermittedContentZeroOrMore
|
|
20
|
+
>
|
|
21
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
22
|
+
import('../types/permitted-structures').PermittedContentChoice
|
|
23
|
+
>
|
|
24
|
+
| import('type-fest/source/readonly-deep').ReadonlyObjectDeep<
|
|
25
|
+
import('../types/permitted-structures').PermittedContentTransparent
|
|
26
|
+
>
|
|
27
|
+
)[]
|
|
28
|
+
| null;
|
|
4
29
|
export {};
|
|
@@ -9,7 +9,7 @@ el, specs) {
|
|
|
9
9
|
var _a, _b;
|
|
10
10
|
const cacheByEl = (_a = cachesBySpecs.get(specs)) !== null && _a !== void 0 ? _a : new Map();
|
|
11
11
|
const cached = cacheByEl.get(el);
|
|
12
|
-
if (cached) {
|
|
12
|
+
if (cached !== undefined) {
|
|
13
13
|
return cached;
|
|
14
14
|
}
|
|
15
15
|
const spec = (0, get_spec_1.getSpec)(el, specs);
|
|
@@ -7,8 +7,9 @@ const get_permitted_roles_1 = require("./get-permitted-roles");
|
|
|
7
7
|
function getExplicitRole(specs,
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
9
|
el, version) {
|
|
10
|
+
var _a;
|
|
10
11
|
const roleValue = el.getAttribute('role');
|
|
11
|
-
const roleNames = (roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g))
|
|
12
|
+
const roleNames = (_a = roleValue === null || roleValue === void 0 ? void 0 : roleValue.toLowerCase().trim().split(/\s+/g)) !== null && _a !== void 0 ? _a : [];
|
|
12
13
|
const permittedRoles = (0, get_permitted_roles_1.getPermittedRoles)(el, version, specs);
|
|
13
14
|
const { namespaceURI } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
|
|
14
15
|
let error = 'NO_EXPLICIT';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
2
|
export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
3
|
-
export declare function getImplicitRoleName(
|
|
3
|
+
export declare function getImplicitRoleName(
|
|
4
|
+
el: Element,
|
|
5
|
+
version: ARIAVersion,
|
|
6
|
+
specs: MLMLSpec,
|
|
7
|
+
): import('..').ImplicitRole;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getNonPresentationalAncestor(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function getNonPresentationalAncestor(
|
|
3
|
+
el: Element,
|
|
4
|
+
specs: MLMLSpec,
|
|
5
|
+
version: ARIAVersion,
|
|
6
|
+
):
|
|
7
|
+
| import('../types').ComputedRole
|
|
8
|
+
| {
|
|
9
|
+
el: null;
|
|
10
|
+
role: null;
|
|
11
|
+
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpec<K extends keyof ElementSpec>(
|
|
2
|
+
export declare function getSpec<K extends keyof ElementSpec>(
|
|
3
|
+
el: Element,
|
|
4
|
+
specs: readonly Pick<ElementSpec, 'name' | K>[],
|
|
5
|
+
): Pick<ElementSpec, 'name' | K> | null;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
2
|
export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
3
|
-
export declare function isRequiredOwnedElement(
|
|
3
|
+
export declare function isRequiredOwnedElement(
|
|
4
|
+
el: Element,
|
|
5
|
+
role: ComputedRole['role'],
|
|
6
|
+
query: string,
|
|
7
|
+
specs: MLMLSpec,
|
|
8
|
+
version: ARIAVersion,
|
|
9
|
+
): boolean;
|
|
@@ -25,7 +25,7 @@ el, specs, version) {
|
|
|
25
25
|
// Return true if the element is unknown, deprecated, or obsolete.
|
|
26
26
|
const { localName, namespace } = (0, resolve_namespace_1.resolveNamespace)(el.localName, el.namespaceURI);
|
|
27
27
|
const spec = (0, get_spec_by_tag_name_1.getSpecByTagName)(specs.specs, localName, namespace);
|
|
28
|
-
if (!spec || spec.deprecated || spec.obsolete) {
|
|
28
|
+
if (!spec || spec.deprecated || spec.obsolete != null) {
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
31
|
// According to HTML and SVG Specs with **the author's interpretation**
|
|
@@ -57,6 +57,7 @@ exports.isExposed = isExposed;
|
|
|
57
57
|
function isExcluding(
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
59
59
|
el, specs, version) {
|
|
60
|
+
var _a;
|
|
60
61
|
/**
|
|
61
62
|
* The following elements are not exposed via the accessibility API and
|
|
62
63
|
* user agents MUST NOT include them in the accessibility tree:
|
|
@@ -81,7 +82,7 @@ el, specs, version) {
|
|
|
81
82
|
* These exceptions and conditions are documented in the presentation (role)
|
|
82
83
|
* section.
|
|
83
84
|
*/
|
|
84
|
-
if ((0, is_presentational_1.isPresentational)((el.getAttribute('role')
|
|
85
|
+
if ((0, is_presentational_1.isPresentational)(((_a = el.getAttribute('role')) !== null && _a !== void 0 ? _a : '').split(/\s+/)[0])) {
|
|
85
86
|
return true;
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function ariaSpecs(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function ariaSpecs(
|
|
3
|
+
specs: MLMLSpec,
|
|
4
|
+
version: ARIAVersion,
|
|
5
|
+
): {
|
|
6
|
+
readonly roles: readonly import('../types').ARIARoleInSchema[];
|
|
7
|
+
readonly graphicsRoles: readonly import('../types').ARIARoleInSchema[];
|
|
8
|
+
readonly props: readonly import('../types').ARIAProperty[];
|
|
6
9
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
2
|
import type { Category } from '../types/permitted-structures';
|
|
3
|
-
export declare function contentModelCategoryToTagNames(
|
|
3
|
+
export declare function contentModelCategoryToTagNames(
|
|
4
|
+
contentModel: Category,
|
|
5
|
+
def: MLMLSpec['def'],
|
|
6
|
+
): ReadonlyArray<string>;
|
package/lib/specs/get-aria.js
CHANGED
|
@@ -52,7 +52,7 @@ function getVersionResolvedARIA(specs, localName, namespace, version) {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
aria = (0, resolve_version_1.resolveVersion)(spec, version);
|
|
55
|
-
if (aria.permittedRoles) {
|
|
55
|
+
if (aria.permittedRoles !== false) {
|
|
56
56
|
aria = {
|
|
57
57
|
...aria,
|
|
58
58
|
permittedRoles: optimizePermittedRoles(aria.permittedRoles),
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { MLMLSpec, Attribute } from '../types';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getAttrSpecs(
|
|
3
|
+
export declare function getAttrSpecs(
|
|
4
|
+
localName: string,
|
|
5
|
+
namespace: NamespaceURI | null,
|
|
6
|
+
schema: MLMLSpec,
|
|
7
|
+
): readonly Attribute[] | null;
|
|
4
8
|
type HasName = {
|
|
5
|
-
|
|
9
|
+
readonly name: string;
|
|
6
10
|
};
|
|
7
11
|
export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
|
|
8
12
|
export {};
|
|
@@ -8,7 +8,7 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
8
8
|
if (!schemaCache.has(schema)) {
|
|
9
9
|
cacheMap.clear();
|
|
10
10
|
}
|
|
11
|
-
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace
|
|
11
|
+
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace !== null && namespace !== void 0 ? namespace : undefined);
|
|
12
12
|
const cache = cacheMap.get(localNameWithNS);
|
|
13
13
|
if (cache !== undefined) {
|
|
14
14
|
return cache;
|
|
@@ -24,7 +24,7 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
24
24
|
for (const catName in elSpec.globalAttrs) {
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
const catAttrs = elSpec.globalAttrs[catName];
|
|
27
|
-
if (
|
|
27
|
+
if (catAttrs === false) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
30
|
if (typeof catAttrs === 'boolean') {
|
|
@@ -66,18 +66,6 @@ function getAttrSpecs(localName, namespace, schema) {
|
|
|
66
66
|
const attr = attrs[name];
|
|
67
67
|
return { name, type: 'Any', ...attr };
|
|
68
68
|
});
|
|
69
|
-
for (const attr of attrList) {
|
|
70
|
-
if (!attr.type) {
|
|
71
|
-
throw new Error(`The type is empty in the ${attr.name} attribute of the ${localName} element,
|
|
72
|
-
'packages',
|
|
73
|
-
'@markuplint',
|
|
74
|
-
'html-spec',
|
|
75
|
-
'src',
|
|
76
|
-
'attributes',
|
|
77
|
-
nameWithNS.replace(':', '_') + '.json',
|
|
78
|
-
)})`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
69
|
attrList.sort(nameCompare);
|
|
82
70
|
cacheMap.set(localNameWithNS, attrList);
|
|
83
71
|
return attrList;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(
|
|
2
|
+
export declare function getImplicitRole(
|
|
3
|
+
specs: MLMLSpec,
|
|
4
|
+
localName: string,
|
|
5
|
+
namespace: string | null,
|
|
6
|
+
version: ARIAVersion,
|
|
7
|
+
matches: Matches,
|
|
8
|
+
): import('..').ImplicitRole;
|
|
@@ -53,11 +53,11 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
|
|
|
53
53
|
return role;
|
|
54
54
|
}));
|
|
55
55
|
}
|
|
56
|
-
if (implicitRole) {
|
|
57
|
-
|
|
58
|
-
return (0, merge_array_1.mergeArray)(implicitRoles.map(r => ({ name: r })), permittedRoleList);
|
|
56
|
+
if (implicitRole === false) {
|
|
57
|
+
return permittedRoleList;
|
|
59
58
|
}
|
|
60
|
-
|
|
59
|
+
const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
|
|
60
|
+
return (0, merge_array_1.mergeArray)(implicitRoles.map(r => ({ name: r })), permittedRoleList);
|
|
61
61
|
}
|
|
62
62
|
exports.getPermittedRoles = getPermittedRoles;
|
|
63
63
|
function isAAMInfo(permittedRoles) {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getRoleSpec(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function getRoleSpec(
|
|
4
|
+
specs: MLMLSpec,
|
|
5
|
+
roleName: string,
|
|
6
|
+
namespace: NamespaceURI,
|
|
7
|
+
version: ARIAVersion,
|
|
8
|
+
):
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
superClassRoles: ARIARoleInSchema[];
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
@@ -38,9 +38,9 @@ function recursiveTraverseSuperClassRoles(specs, roleName, namespace, version) {
|
|
|
38
38
|
return roles;
|
|
39
39
|
}
|
|
40
40
|
function getSuperClassRoles(specs, roleName, namespace, version) {
|
|
41
|
-
var _a;
|
|
41
|
+
var _a, _b;
|
|
42
42
|
const role = getRoleByName(specs, roleName, namespace, version);
|
|
43
|
-
return (((_a = role === null || role === void 0 ? void 0 : role.generalization) === null || _a === void 0 ? void 0 : _a.map(roleName => getRoleByName(specs, roleName, namespace, version)).filter((role) => !!role))
|
|
43
|
+
return ((_b = (_a = role === null || role === void 0 ? void 0 : role.generalization) === null || _a === void 0 ? void 0 : _a.map(roleName => getRoleByName(specs, roleName, namespace, version)).filter((role) => !!role)) !== null && _b !== void 0 ? _b : null);
|
|
44
44
|
}
|
|
45
45
|
function getRoleByName(specs, roleName, namespace, version) {
|
|
46
46
|
const { roles, graphicsRoles } = (0, aria_specs_1.ariaSpecs)(specs, version);
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSelectorsByContentModelCategory = void 0;
|
|
4
4
|
function getSelectorsByContentModelCategory(specs, category) {
|
|
5
5
|
const selectors = specs.def['#contentModels'][category];
|
|
6
|
-
return selectors
|
|
6
|
+
return selectors !== null && selectors !== void 0 ? selectors : [];
|
|
7
7
|
}
|
|
8
8
|
exports.getSelectorsByContentModelCategory = getSelectorsByContentModelCategory;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(
|
|
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;
|
|
@@ -4,12 +4,13 @@ exports.getSpecByTagName = void 0;
|
|
|
4
4
|
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
5
5
|
const cache = new Map();
|
|
6
6
|
function getSpecByTagName(specs, localName, namespace) {
|
|
7
|
-
|
|
7
|
+
var _a;
|
|
8
|
+
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace !== null && namespace !== void 0 ? namespace : undefined);
|
|
8
9
|
let spec = cache.get(localNameWithNS);
|
|
9
10
|
if (spec !== undefined) {
|
|
10
11
|
return spec;
|
|
11
12
|
}
|
|
12
|
-
spec = specs.find(spec => spec.name === localNameWithNS)
|
|
13
|
+
spec = (_a = specs.find(spec => spec.name === localNameWithNS)) !== null && _a !== void 0 ? _a : null;
|
|
13
14
|
cache.set(localNameWithNS, spec);
|
|
14
15
|
return spec;
|
|
15
16
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function isPalpableElement(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function isPalpableElement(
|
|
3
|
+
el: Element,
|
|
4
|
+
specs: MLMLSpec,
|
|
5
|
+
options?: {
|
|
6
|
+
readonly extendsSvg?: boolean;
|
|
7
|
+
readonly extendsExposableElements?: boolean;
|
|
8
|
+
},
|
|
9
|
+
): boolean;
|
|
@@ -34,10 +34,10 @@ const exposableElementsThatAreNoBelongingAModel = [
|
|
|
34
34
|
function isPalpableElement(
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
36
36
|
el, specs, options) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const conditions = [((_a = specs.def['#contentModels']['#palpable']) === null || _a === void 0 ? void 0 : _a.join(','))
|
|
37
|
+
var _a, _b, _c, _d;
|
|
38
|
+
const conditions = [(_b = (_a = specs.def['#contentModels']['#palpable']) === null || _a === void 0 ? void 0 : _a.join(',')) !== null && _b !== void 0 ? _b : ''];
|
|
39
39
|
if ((options === null || options === void 0 ? void 0 : options.extendsSvg) !== false /* default true */) {
|
|
40
|
-
conditions.push(((
|
|
40
|
+
conditions.push((_d = (_c = specs.def['#contentModels']['#SVGRenderable']) === null || _c === void 0 ? void 0 : _c.join(',')) !== null && _d !== void 0 ? _d : '');
|
|
41
41
|
}
|
|
42
42
|
if (options === null || options === void 0 ? void 0 : options.extendsExposableElements /* default false */) {
|
|
43
43
|
conditions.push(exposableElementsThatAreNoBelongingAModel.join(','));
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ARIAVersion } from '../types';
|
|
2
2
|
import type { ARIA } from '../types/aria';
|
|
3
3
|
import type { ReadonlyDeep } from 'type-fest';
|
|
4
|
-
export declare function resolveVersion(
|
|
4
|
+
export declare function resolveVersion(
|
|
5
|
+
aria: ReadonlyDeep<ARIA>,
|
|
6
|
+
version: ARIAVersion,
|
|
7
|
+
): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
|
|
@@ -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').Cites;
|
|
11
|
+
def: import('../types').SpecDefs;
|
|
12
|
+
specs: readonly ElementSpec[];
|
|
13
13
|
};
|