@markuplint/ml-spec 3.0.0-dev.24 → 3.0.0-dev.290

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.
Files changed (131) hide show
  1. package/lib/constant/aria-version.d.ts +2 -0
  2. package/lib/constant/aria-version.js +2 -0
  3. package/lib/dom-traverse/accname-computation.js +6 -7
  4. package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
  5. package/lib/dom-traverse/get-attr-specs.js +5 -7
  6. package/lib/dom-traverse/get-computed-aria-props.d.ts +2 -2
  7. package/lib/dom-traverse/get-computed-aria-props.js +10 -13
  8. package/lib/dom-traverse/get-computed-role.d.ts +2 -2
  9. package/lib/dom-traverse/get-computed-role.js +104 -31
  10. package/lib/dom-traverse/get-content-model.d.ts +4 -3
  11. package/lib/dom-traverse/get-content-model.js +8 -11
  12. package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
  13. package/lib/dom-traverse/get-explicit-role.js +14 -14
  14. package/lib/dom-traverse/get-implicit-role.d.ts +3 -3
  15. package/lib/dom-traverse/get-implicit-role.js +12 -13
  16. package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
  17. package/lib/dom-traverse/get-non-presentational-ancestor.js +13 -10
  18. package/lib/dom-traverse/get-permitted-roles.d.ts +4 -4
  19. package/lib/dom-traverse/get-permitted-roles.js +5 -7
  20. package/lib/dom-traverse/get-spec.d.ts +2 -2
  21. package/lib/dom-traverse/get-spec.js +5 -7
  22. package/lib/dom-traverse/has-required-owned-elements.d.ts +3 -3
  23. package/lib/dom-traverse/has-required-owned-elements.js +21 -22
  24. package/lib/dom-traverse/is-exposed.d.ts +2 -2
  25. package/lib/dom-traverse/is-exposed.js +47 -18
  26. package/lib/dom-traverse/matches-context-role.d.ts +2 -0
  27. package/lib/dom-traverse/matches-context-role.js +23 -0
  28. package/lib/dom-traverse/may-be-focusable.d.ts +2 -2
  29. package/lib/dom-traverse/may-be-focusable.js +5 -7
  30. package/lib/index.d.ts +28 -24
  31. package/lib/index.js +28 -27
  32. package/lib/specs/aria-specs.d.ts +5 -5
  33. package/lib/specs/aria-specs.js +1 -5
  34. package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
  35. package/lib/specs/content-model-category-to-tag-names.js +1 -5
  36. package/lib/specs/get-aria.d.ts +4 -3
  37. package/lib/specs/get-aria.js +18 -18
  38. package/lib/specs/get-attr-specs.d.ts +3 -3
  39. package/lib/specs/get-attr-specs.js +5 -22
  40. package/lib/specs/get-implicit-role.d.ts +2 -2
  41. package/lib/specs/get-implicit-role.js +3 -7
  42. package/lib/specs/get-permitted-roles.d.ts +4 -4
  43. package/lib/specs/get-permitted-roles.js +29 -28
  44. package/lib/specs/get-role-spec.d.ts +2 -2
  45. package/lib/specs/get-role-spec.js +10 -14
  46. package/lib/specs/get-selectors-by-content-model-category.d.ts +3 -3
  47. package/lib/specs/get-selectors-by-content-model-category.js +2 -6
  48. package/lib/specs/get-spec-by-tag-name.d.ts +2 -2
  49. package/lib/specs/get-spec-by-tag-name.js +4 -8
  50. package/lib/specs/is-nothing-content-model.js +5 -7
  51. package/lib/specs/is-palpable-elements.d.ts +4 -4
  52. package/lib/specs/is-palpable-elements.js +7 -10
  53. package/lib/specs/is-presentational.js +1 -5
  54. package/lib/specs/is-void-element.js +3 -5
  55. package/lib/specs/resolve-version.d.ts +4 -3
  56. package/lib/specs/resolve-version.js +7 -12
  57. package/lib/specs/schema-to-spec.d.ts +4 -4
  58. package/lib/specs/schema-to-spec.js +30 -24
  59. package/lib/types/aria.d.ts +25 -4
  60. package/lib/types/aria.js +1 -3
  61. package/lib/types/attributes.d.ts +3 -4
  62. package/lib/types/attributes.js +1 -3
  63. package/lib/types/index.d.ts +93 -92
  64. package/lib/types/index.js +1 -2
  65. package/lib/types/permitted-structures.d.ts +6 -2
  66. package/lib/types/permitted-structures.js +1 -3
  67. package/lib/utils/get-ns.js +1 -5
  68. package/lib/utils/merge-array.d.ts +2 -2
  69. package/lib/utils/merge-array.js +1 -5
  70. package/lib/utils/resolve-namespace.js +4 -8
  71. package/lib/utils/validateAriaVersion.d.ts +2 -0
  72. package/lib/utils/validateAriaVersion.js +4 -0
  73. package/package.json +20 -10
  74. package/lib/types/permitted-structres.d.ts +0 -58
  75. package/lib/types/permitted-structres.js +0 -8
  76. package/schemas/aria.schema.json +0 -258
  77. package/schemas/attributes.schema.json +0 -204
  78. package/schemas/content-models.schema.json +0 -199
  79. package/schemas/element.schema.json +0 -11
  80. package/schemas/global-attributes.schema.json +0 -761
  81. package/src/dom-traverse/accname-computation.spec.ts +0 -69
  82. package/src/dom-traverse/accname-computation.ts +0 -5
  83. package/src/dom-traverse/get-attr-specs.ts +0 -8
  84. package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
  85. package/src/dom-traverse/get-computed-aria-props.ts +0 -130
  86. package/src/dom-traverse/get-computed-role.spec.ts +0 -134
  87. package/src/dom-traverse/get-computed-role.ts +0 -181
  88. package/src/dom-traverse/get-content-model.ts +0 -32
  89. package/src/dom-traverse/get-explicit-role.ts +0 -112
  90. package/src/dom-traverse/get-implicit-role.ts +0 -36
  91. package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
  92. package/src/dom-traverse/get-permitted-roles.ts +0 -7
  93. package/src/dom-traverse/get-spec.ts +0 -7
  94. package/src/dom-traverse/has-required-owned-elements.spec.ts +0 -36
  95. package/src/dom-traverse/has-required-owned-elements.ts +0 -85
  96. package/src/dom-traverse/is-exposed.spec.ts +0 -50
  97. package/src/dom-traverse/is-exposed.ts +0 -196
  98. package/src/dom-traverse/may-be-focusable.ts +0 -21
  99. package/src/index.ts +0 -24
  100. package/src/specs/aria-specs.ts +0 -6
  101. package/src/specs/content-model-category-to-tag-names.ts +0 -15
  102. package/src/specs/get-aria.ts +0 -85
  103. package/src/specs/get-attr-specs.spec.ts +0 -47
  104. package/src/specs/get-attr-specs.ts +0 -116
  105. package/src/specs/get-implicit-role.spec.ts +0 -81
  106. package/src/specs/get-implicit-role.ts +0 -17
  107. package/src/specs/get-permitted-roles.spec.ts +0 -420
  108. package/src/specs/get-permitted-roles.ts +0 -87
  109. package/src/specs/get-role-spec.spec.ts +0 -67
  110. package/src/specs/get-role-spec.ts +0 -72
  111. package/src/specs/get-selectors-by-content-model-category.ts +0 -10
  112. package/src/specs/get-spec-by-tag-name.spec.ts +0 -68
  113. package/src/specs/get-spec-by-tag-name.ts +0 -20
  114. package/src/specs/is-nothing-content-model.ts +0 -9
  115. package/src/specs/is-palpable-elements.ts +0 -55
  116. package/src/specs/is-presentational.ts +0 -6
  117. package/src/specs/is-void-element.ts +0 -22
  118. package/src/specs/resolve-version.ts +0 -20
  119. package/src/specs/schema-to-spec.spec.ts +0 -39
  120. package/src/specs/schema-to-spec.ts +0 -103
  121. package/src/types/aria.ts +0 -153
  122. package/src/types/attributes.ts +0 -1524
  123. package/src/types/index.ts +0 -255
  124. package/src/types/permitted-structres.ts +0 -100
  125. package/src/types/permitted-structures.ts +0 -96
  126. package/src/utils/get-ns.ts +0 -18
  127. package/src/utils/merge-array.ts +0 -35
  128. package/src/utils/resolve-namespace.spec.ts +0 -37
  129. package/src/utils/resolve-namespace.ts +0 -40
  130. package/tsconfig.test.json +0 -3
  131. package/tsconfig.tsbuildinfo +0 -1
@@ -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,7 +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(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): {
10
- name: string;
11
- 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;
12
12
  }[];
@@ -1,9 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPermittedRoles = void 0;
4
- const merge_array_1 = require("../utils/merge-array");
5
- const aria_specs_1 = require("./aria-specs");
6
- 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';
7
6
  /**
8
7
  * Getting permitted ARIA roles.
9
8
  *
@@ -11,51 +10,53 @@ const get_aria_1 = require("./get-aria");
11
10
  * - If `true`, this mean is "Any".
12
11
  * - If `false`, this mean is "No".
13
12
  */
14
- function getPermittedRoles(specs, localName, namespace, version, matches) {
15
- const aria = (0, get_aria_1.getARIA)(specs, localName, namespace, version, matches);
13
+ export function getPermittedRoles(specs, localName, namespace, version, matches) {
14
+ const aria = getARIA(specs, localName, namespace, version, matches);
16
15
  if (!aria) {
17
16
  return [];
18
17
  }
19
18
  const { implicitRole, permittedRoles } = aria;
20
- const { roles, graphicsRoles } = (0, aria_specs_1.ariaSpecs)(specs, version);
19
+ const { roles, graphicsRoles } = ariaSpecs(specs, version);
21
20
  let permittedRoleList = [];
22
21
  if (permittedRoles === true) {
23
- permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, roles
22
+ permittedRoleList = mergeArray(permittedRoleList, roles
24
23
  .filter(role => !role.isAbstract)
25
24
  .map(role => ({
26
25
  name: role.name,
27
26
  })));
28
27
  }
29
- if (Array.isArray(permittedRoles)) {
30
- permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
31
- if (typeof role === 'string') {
32
- return {
33
- name: role,
34
- };
35
- }
36
- return role;
37
- }));
38
- }
39
- else if (!(typeof permittedRoles === 'boolean')) {
28
+ if (isAAMInfo(permittedRoles)) {
40
29
  if (permittedRoles['core-aam']) {
41
- permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, roles
30
+ permittedRoleList = mergeArray(permittedRoleList, roles
42
31
  .filter(role => !role.isAbstract)
43
32
  .map(role => ({
44
33
  name: role.name,
45
34
  })));
46
35
  }
47
36
  if (permittedRoles['graphics-aam']) {
48
- permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, graphicsRoles
37
+ permittedRoleList = mergeArray(permittedRoleList, graphicsRoles
49
38
  .filter(role => !role.isAbstract)
50
39
  .map(role => ({
51
40
  name: role.name,
52
41
  })));
53
42
  }
54
43
  }
55
- if (implicitRole) {
56
- const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
57
- return (0, merge_array_1.mergeArray)(implicitRoles.map(r => ({ name: r })), permittedRoleList);
44
+ else if (typeof permittedRoles !== 'boolean') {
45
+ permittedRoleList = mergeArray(permittedRoleList, permittedRoles.map(role => {
46
+ if (typeof role === 'string') {
47
+ return {
48
+ name: role,
49
+ };
50
+ }
51
+ return role;
52
+ }));
58
53
  }
59
- return permittedRoleList;
54
+ if (implicitRole === false) {
55
+ return permittedRoleList;
56
+ }
57
+ const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
58
+ return mergeArray(implicitRoles.map(r => ({ name: r })), permittedRoleList);
59
+ }
60
+ function isAAMInfo(permittedRoles) {
61
+ return isPlainObject(permittedRoles);
60
62
  }
61
- exports.getPermittedRoles = getPermittedRoles;
@@ -1,5 +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(specs: Readonly<MLMLSpec>, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
3
+ export declare function getRoleSpec(specs: MLMLSpec, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
4
4
  superClassRoles: ARIARoleInSchema[];
5
5
  }) | null;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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: (_a = role.requiredContextRole) !== null && _a !== void 0 ? _a : [],
16
- requiredOwnedElements: (_b = role.requiredOwnedElements) !== null && _b !== void 0 ? _b : [],
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: (_c = role.ownedProperties) !== null && _c !== void 0 ? _c : [],
23
- prohibitedProperties: (_d = role.prohibitedProperties) !== null && _d !== void 0 ? _d : [],
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;
42
36
  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)) || null);
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 } = (0, aria_specs_1.ariaSpecs)(specs, version);
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';
3
- export declare function getSelectorsByContentModelCategory(specs: Readonly<MLMLSpec>, category: Category): ReadonlyArray<string>;
1
+ import type { MLMLSpec } from '../types/index.js';
2
+ import type { Category } from '../types/permitted-structures.js';
3
+ export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
@@ -1,8 +1,4 @@
1
- "use strict";
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,2 +1,2 @@
1
- import type { ElementSpec } from '../types';
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
+ 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,16 +1,12 @@
1
- "use strict";
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
- const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace || undefined);
3
+ export function getSpecByTagName(specs, localName, namespace) {
4
+ const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined);
8
5
  let spec = cache.get(localNameWithNS);
9
6
  if (spec !== undefined) {
10
7
  return spec;
11
8
  }
12
- spec = specs.find(spec => spec.name === localNameWithNS) || null;
9
+ spec = specs.find(spec => spec.name === localNameWithNS) ?? null;
13
10
  cache.set(localNameWithNS, spec);
14
11
  return spec;
15
12
  }
16
- exports.getSpecByTagName = getSpecByTagName;
@@ -1,12 +1,10 @@
1
- "use strict";
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(el) {
10
- return (0, is_void_element_1.isVoidElement)(el) || ['iframe', 'template'].includes(el.localName);
6
+ export function isNothingContentModel(
7
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
+ el) {
9
+ return isVoidElement(el) || ['iframe', 'template'].includes(el.localName);
11
10
  }
12
- exports.isNothingContentModel = isNothingContentModel;
@@ -1,5 +1,5 @@
1
- import type { MLMLSpec } from '../types';
2
- export declare function isPalpableElement(el: Element, specs: Readonly<MLMLSpec>, options?: {
3
- extendsSvg?: boolean;
4
- extendsExposableElements?: 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
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,17 +28,17 @@ const exposableElementsThatAreNoBelongingAModel = [
31
28
  'thead',
32
29
  'tr',
33
30
  ];
34
- function isPalpableElement(el, specs, options) {
35
- var _a, _b;
36
- const conditions = [((_a = specs.def['#contentModels']['#palpable']) === null || _a === void 0 ? void 0 : _a.join(',')) || ''];
37
- if ((options === null || options === void 0 ? void 0 : options.extendsSvg) !== false /* default true */) {
38
- conditions.push(((_b = specs.def['#contentModels']['#SVGRenderable']) === null || _b === void 0 ? void 0 : _b.join(',')) || '');
31
+ export function isPalpableElement(
32
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
33
+ el, specs, options) {
34
+ const conditions = [specs.def['#contentModels']['#palpable']?.join(',') ?? ''];
35
+ if (options?.extendsSvg !== false /* default true */) {
36
+ conditions.push(specs.def['#contentModels']['#SVGRenderable']?.join(',') ?? '');
39
37
  }
40
- if (options === null || options === void 0 ? void 0 : options.extendsExposableElements /* default false */) {
38
+ if (options?.extendsExposableElements /* default false */) {
41
39
  conditions.push(exposableElementsThatAreNoBelongingAModel.join(','));
42
40
  }
43
41
  return conditions.some(condition => {
44
42
  return el.matches(condition);
45
43
  });
46
44
  }
47
- exports.isPalpableElement = isPalpableElement;
@@ -1,10 +1,6 @@
1
- "use strict";
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,6 +1,3 @@
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
  */
@@ -19,7 +16,8 @@ const voidElements = [
19
16
  'track',
20
17
  'wbr',
21
18
  ];
22
- function isVoidElement(el) {
19
+ export function isVoidElement(
20
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
21
+ el) {
23
22
  return voidElements.includes(el.localName);
24
23
  }
25
- exports.isVoidElement = isVoidElement;
@@ -1,3 +1,4 @@
1
- import type { ARIAVersion } from '../types';
2
- import type { ARIA } from '../types/aria';
3
- export declare function resolveVersion(aria: ARIA, version: ARIAVersion): Omit<ARIA, ARIAVersion>;
1
+ import type { ARIA } from '../types/aria.js';
2
+ import type { ARIAVersion } from '../types/index.js';
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function resolveVersion(aria: ReadonlyDeep<ARIA>, version: ARIAVersion): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveVersion = void 0;
4
- function resolveVersion(aria, version) {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6
- const implicitRole = (_b = (_a = aria[version]) === null || _a === void 0 ? void 0 : _a.implicitRole) !== null && _b !== void 0 ? _b : aria.implicitRole;
7
- const permittedRoles = (_d = (_c = aria[version]) === null || _c === void 0 ? void 0 : _c.permittedRoles) !== null && _d !== void 0 ? _d : aria.permittedRoles;
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.2' ? (_k = (_j = aria[version]) === null || _j === void 0 ? void 0 : _j.namingProhibited) !== null && _k !== void 0 ? _k : aria.namingProhibited : 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
- cites: import("../types").Cites;
11
- def: import("../types").SpecDefs;
12
- specs: ElementSpec[];
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
- "use strict";
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;
9
+ export function schemaToSpec(schemas) {
14
10
  const [main, ...extendedSpecs] = schemas;
15
11
  const result = { ...main };
16
12
  for (const extendedSpec of extendedSpecs) {
@@ -18,37 +14,48 @@ function schemaToSpec(schemas) {
18
14
  result.cites = [...result.cites, ...extendedSpec.cites];
19
15
  }
20
16
  if (extendedSpec.def) {
21
- if ((_a = extendedSpec.def['#globalAttrs']) === null || _a === void 0 ? void 0 : _a['#extends']) {
22
- result.def['#globalAttrs']['#HTMLGlobalAttrs'] = {
23
- ...(((_b = result.def['#globalAttrs']) === null || _b === void 0 ? void 0 : _b['#HTMLGlobalAttrs']) || {}),
24
- ...(((_c = extendedSpec.def['#globalAttrs']) === null || _c === void 0 ? void 0 : _c['#extends']) || {}),
17
+ const def = { ...result.def };
18
+ if (extendedSpec.def['#globalAttrs']?.['#extends']) {
19
+ const gAttrs = { ...def['#globalAttrs'] };
20
+ gAttrs['#HTMLGlobalAttrs'] = {
21
+ ...(def['#globalAttrs']?.['#HTMLGlobalAttrs'] ?? {}),
22
+ ...(extendedSpec.def['#globalAttrs']?.['#extends'] ?? {}),
25
23
  };
24
+ def['#globalAttrs'] = gAttrs;
26
25
  }
27
26
  if (extendedSpec.def['#aria']) {
28
- result.def['#aria'] = {
27
+ def['#aria'] = {
29
28
  '1.1': {
30
- roles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.1'].roles, extendedSpec.def['#aria']['1.1'].roles),
31
- props: (0, merge_array_1.mergeArray)(result.def['#aria']['1.1'].props, extendedSpec.def['#aria']['1.1'].props),
32
- graphicsRoles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.1'].graphicsRoles, extendedSpec.def['#aria']['1.1'].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),
33
32
  },
34
33
  '1.2': {
35
- roles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.2'].roles, extendedSpec.def['#aria']['1.2'].roles),
36
- props: (0, merge_array_1.mergeArray)(result.def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
37
- graphicsRoles: (0, merge_array_1.mergeArray)(result.def['#aria']['1.2'].graphicsRoles, extendedSpec.def['#aria']['1.2'].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),
37
+ },
38
+ '1.3': {
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),
38
42
  },
39
43
  };
40
44
  }
41
45
  if (extendedSpec.def['#contentModels']) {
46
+ const models = { ...def['#contentModels'] };
42
47
  const keys = new Set([
43
- ...Object.keys(result.def['#contentModels']),
48
+ ...Object.keys(def['#contentModels']),
44
49
  ...Object.keys(extendedSpec.def['#contentModels']),
45
50
  ]);
46
51
  for (const modelName of keys) {
47
- const mainModel = result.def['#contentModels'][modelName];
52
+ const mainModel = def['#contentModels'][modelName];
48
53
  const exModel = extendedSpec.def['#contentModels'][modelName];
49
- result.def['#contentModels'][modelName] = [...(mainModel || []), ...(exModel || [])];
54
+ models[modelName] = [...(mainModel ?? []), ...(exModel ?? [])];
50
55
  }
56
+ def['#contentModels'] = models;
51
57
  }
58
+ result.def = def;
52
59
  }
53
60
  if (extendedSpec.specs) {
54
61
  const exSpecs = extendedSpec.specs.slice();
@@ -66,10 +73,10 @@ function schemaToSpec(schemas) {
66
73
  ...exSpec,
67
74
  globalAttrs: {
68
75
  ...elSpec.globalAttrs,
69
- ...exSpec.globalAttrs,
76
+ ...exSpec?.globalAttrs,
70
77
  },
71
- attributes: mergeAttrSpec(elSpec.attributes, exSpec.attributes),
72
- categories: (0, merge_array_1.mergeArray)(elSpec.categories, exSpec.categories),
78
+ attributes: mergeAttrSpec(elSpec.attributes, exSpec?.attributes),
79
+ categories: mergeArray(elSpec.categories, exSpec?.categories),
73
80
  });
74
81
  }
75
82
  result.specs = specs;
@@ -77,7 +84,6 @@ function schemaToSpec(schemas) {
77
84
  }
78
85
  return result;
79
86
  }
80
- exports.schemaToSpec = schemaToSpec;
81
87
  function mergeAttrSpec(std, ex = {}) {
82
88
  const result = {};
83
89
  const keys = Array.from(new Set([...Object.keys(std), ...Object.keys(ex)]));
@@ -14,10 +14,7 @@ export type PermittedRoles = boolean | (string | {
14
14
  name: string;
15
15
  deprecated?: true;
16
16
  [k: string]: unknown;
17
- })[] | {
18
- 'core-aam'?: true;
19
- 'graphics-aam'?: true;
20
- };
17
+ })[] | PermittedARIAAAMInfo;
21
18
  /**
22
19
  * If set false:
23
20
  * > No role or aria-* attributes
@@ -88,6 +85,26 @@ export interface ARIA {
88
85
  properties?: PermittedARIAProperties;
89
86
  };
90
87
  };
88
+ '1.3'?: {
89
+ implicitRole?: ImplicitRole;
90
+ permittedRoles?: PermittedRoles;
91
+ namingProhibited?: true;
92
+ implicitProperties?: ImplicitProperties;
93
+ properties?: PermittedARIAProperties;
94
+ conditions?: {
95
+ /**
96
+ * This interface was referenced by `undefined`'s JSON-Schema definition
97
+ * via the `patternProperty` ".+".
98
+ */
99
+ [k: string]: {
100
+ implicitRole?: ImplicitRole;
101
+ permittedRoles?: PermittedRoles;
102
+ namingProhibited?: true;
103
+ implicitProperties?: ImplicitProperties;
104
+ properties?: PermittedARIAProperties;
105
+ };
106
+ };
107
+ };
91
108
  '1.2'?: {
92
109
  implicitRole?: ImplicitRole;
93
110
  permittedRoles?: PermittedRoles;
@@ -127,6 +144,10 @@ export interface ARIA {
127
144
  };
128
145
  };
129
146
  }
147
+ export interface PermittedARIAAAMInfo {
148
+ 'core-aam'?: true;
149
+ 'graphics-aam'?: true;
150
+ }
130
151
  export interface ImplicitProperties {
131
152
  /**
132
153
  * This interface was referenced by `ImplicitProperties`'s JSON-Schema definition
package/lib/types/aria.js CHANGED
@@ -1,8 +1,6 @@
1
- "use strict";
2
- /* tslint:disable */
3
1
  /**
4
2
  * This file was automatically generated by json-schema-to-typescript.
5
3
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
6
4
  * and run json-schema-to-typescript to regenerate this file.
7
5
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
6
+ export {};