@markuplint/ml-spec 3.0.0-canary.5 → 3.0.0-dev.176

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 (128) hide show
  1. package/README.md +1 -1
  2. package/lib/constant/aria-version.d.ts +2 -0
  3. package/lib/constant/aria-version.js +5 -0
  4. package/lib/dom-traverse/accname-computation.js +3 -1
  5. package/lib/dom-traverse/get-attr-specs.d.ts +1 -1
  6. package/lib/dom-traverse/get-attr-specs.js +3 -1
  7. package/lib/dom-traverse/get-computed-aria-props.d.ts +6 -6
  8. package/lib/dom-traverse/get-computed-aria-props.js +4 -2
  9. package/lib/dom-traverse/get-computed-role.d.ts +6 -1
  10. package/lib/dom-traverse/get-computed-role.js +41 -10
  11. package/lib/dom-traverse/get-content-model.d.ts +28 -2
  12. package/lib/dom-traverse/get-content-model.js +4 -2
  13. package/lib/dom-traverse/get-explicit-role.js +9 -4
  14. package/lib/dom-traverse/get-implicit-role.d.ts +6 -2
  15. package/lib/dom-traverse/get-implicit-role.js +6 -2
  16. package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +10 -4
  17. package/lib/dom-traverse/get-non-presentational-ancestor.js +10 -2
  18. package/lib/dom-traverse/get-permitted-roles.d.ts +7 -3
  19. package/lib/dom-traverse/get-permitted-roles.js +3 -1
  20. package/lib/dom-traverse/get-spec.d.ts +4 -1
  21. package/lib/dom-traverse/get-spec.js +3 -1
  22. package/lib/dom-traverse/has-required-owned-elements.d.ts +8 -2
  23. package/lib/dom-traverse/has-required-owned-elements.js +14 -8
  24. package/lib/dom-traverse/is-exposed.d.ts +1 -1
  25. package/lib/dom-traverse/is-exposed.js +43 -7
  26. package/lib/dom-traverse/matches-context-role.d.ts +7 -0
  27. package/lib/dom-traverse/matches-context-role.js +27 -0
  28. package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
  29. package/lib/dom-traverse/may-be-focusable.js +3 -1
  30. package/lib/index.d.ts +4 -0
  31. package/lib/index.js +4 -0
  32. package/lib/specs/aria-specs.d.ts +7 -4
  33. package/lib/specs/content-model-category-to-tag-names.d.ts +4 -1
  34. package/lib/specs/get-aria.d.ts +8 -1
  35. package/lib/specs/get-aria.js +8 -2
  36. package/lib/specs/get-attr-specs.d.ts +6 -2
  37. package/lib/specs/get-attr-specs.js +2 -14
  38. package/lib/specs/get-implicit-role.d.ts +7 -1
  39. package/lib/specs/get-permitted-roles.d.ts +9 -3
  40. package/lib/specs/get-permitted-roles.js +19 -15
  41. package/lib/specs/get-role-spec.d.ts +10 -3
  42. package/lib/specs/get-role-spec.js +2 -2
  43. package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -1
  44. package/lib/specs/get-selectors-by-content-model-category.js +1 -1
  45. package/lib/specs/get-spec-by-tag-name.d.ts +5 -1
  46. package/lib/specs/get-spec-by-tag-name.js +3 -2
  47. package/lib/specs/is-nothing-content-model.d.ts +5 -0
  48. package/lib/specs/is-nothing-content-model.js +14 -0
  49. package/lib/specs/is-palpable-elements.d.ts +8 -4
  50. package/lib/specs/is-palpable-elements.js +6 -4
  51. package/lib/specs/is-void-element.js +3 -1
  52. package/lib/specs/resolve-version.d.ts +5 -1
  53. package/lib/specs/resolve-version.js +1 -1
  54. package/lib/specs/schema-to-spec.d.ts +4 -4
  55. package/lib/specs/schema-to-spec.js +29 -18
  56. package/lib/types/aria.d.ts +149 -114
  57. package/lib/types/attributes.d.ts +1490 -111
  58. package/lib/types/index.d.ts +178 -149
  59. package/lib/types/permitted-structures.d.ts +74 -31
  60. package/lib/utils/merge-array.d.ts +9 -4
  61. package/lib/utils/resolve-namespace.d.ts +4 -4
  62. package/lib/utils/resolve-namespace.js +3 -2
  63. package/lib/utils/validateAriaVersion.d.ts +2 -0
  64. package/lib/utils/validateAriaVersion.js +8 -0
  65. package/package.json +13 -8
  66. package/{src/dom-traverse/accname-computation.spec.ts → test/dom-traverse/accname-computation.spec.js} +4 -4
  67. package/test/dom-traverse/get-computed-aria-props.spec.js +758 -0
  68. package/test/dom-traverse/get-computed-role.spec.js +294 -0
  69. package/test/dom-traverse/get-implicit-role.spec.js +40 -0
  70. package/{src/dom-traverse/has-required-owned-elements.spec.ts → test/dom-traverse/has-required-owned-elements.spec.js} +7 -9
  71. package/{src/dom-traverse/is-exposed.spec.ts → test/dom-traverse/is-exposed.spec.js} +29 -9
  72. package/test/dom-traverse/matches-context-role.spec.js +60 -0
  73. package/{src/specs/get-attr-specs.spec.ts → test/specs/get-attr-specs.spec.js} +2 -8
  74. package/{src/specs/get-implicit-role.spec.ts → test/specs/get-implicit-role.spec.js} +9 -11
  75. package/{src/specs/get-permitted-roles.spec.ts → test/specs/get-permitted-roles.spec.js} +8 -10
  76. package/{src/specs/get-role-spec.spec.ts → test/specs/get-role-spec.spec.js} +4 -4
  77. package/{src/specs/get-spec-by-tag-name.spec.ts → test/specs/get-spec-by-tag-name.spec.js} +2 -2
  78. package/test/specs/resolve-version.spec.js +34 -0
  79. package/test/specs/schema-to-spec.spec.js +61 -0
  80. package/{src/utils/resolve-namespace.spec.ts → test/utils/resolve-namespace.spec.js} +1 -1
  81. package/lib/types/permitted-structres.d.ts +0 -58
  82. package/lib/types/permitted-structres.js +0 -8
  83. package/schemas/aria.schema.json +0 -258
  84. package/schemas/attributes.schema.json +0 -204
  85. package/schemas/content-models.schema.json +0 -199
  86. package/schemas/element.schema.json +0 -11
  87. package/schemas/global-attributes.schema.json +0 -761
  88. package/src/dom-traverse/accname-computation.ts +0 -5
  89. package/src/dom-traverse/get-attr-specs.ts +0 -8
  90. package/src/dom-traverse/get-computed-aria-props.spec.ts +0 -368
  91. package/src/dom-traverse/get-computed-aria-props.ts +0 -130
  92. package/src/dom-traverse/get-computed-role.spec.ts +0 -134
  93. package/src/dom-traverse/get-computed-role.ts +0 -181
  94. package/src/dom-traverse/get-content-model.ts +0 -32
  95. package/src/dom-traverse/get-explicit-role.ts +0 -112
  96. package/src/dom-traverse/get-implicit-role.ts +0 -36
  97. package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
  98. package/src/dom-traverse/get-permitted-roles.ts +0 -7
  99. package/src/dom-traverse/get-spec.ts +0 -7
  100. package/src/dom-traverse/has-required-owned-elements.ts +0 -85
  101. package/src/dom-traverse/is-exposed.ts +0 -196
  102. package/src/dom-traverse/may-be-focusable.ts +0 -21
  103. package/src/index.ts +0 -23
  104. package/src/specs/aria-specs.ts +0 -6
  105. package/src/specs/content-model-category-to-tag-names.ts +0 -15
  106. package/src/specs/get-aria.ts +0 -85
  107. package/src/specs/get-attr-specs.ts +0 -116
  108. package/src/specs/get-implicit-role.ts +0 -17
  109. package/src/specs/get-permitted-roles.ts +0 -87
  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.ts +0 -20
  113. package/src/specs/is-palpable-elements.ts +0 -55
  114. package/src/specs/is-presentational.ts +0 -6
  115. package/src/specs/is-void-element.ts +0 -22
  116. package/src/specs/resolve-version.ts +0 -20
  117. package/src/specs/schema-to-spec.spec.ts +0 -39
  118. package/src/specs/schema-to-spec.ts +0 -103
  119. package/src/types/aria.ts +0 -153
  120. package/src/types/attributes.ts +0 -1473
  121. package/src/types/index.ts +0 -255
  122. package/src/types/permitted-structres.ts +0 -100
  123. package/src/types/permitted-structures.ts +0 -96
  124. package/src/utils/get-ns.ts +0 -18
  125. package/src/utils/merge-array.ts +0 -35
  126. package/src/utils/resolve-namespace.ts +0 -40
  127. package/tsconfig.test.json +0 -3
  128. package/tsconfig.tsbuildinfo +0 -1
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './constant/aria-version';
1
2
  export * from './dom-traverse/accname-computation';
2
3
  export * from './dom-traverse/get-attr-specs';
3
4
  export * from './dom-traverse/get-computed-aria-props';
@@ -11,8 +12,10 @@ export * from './dom-traverse/is-exposed';
11
12
  export * from './dom-traverse/may-be-focusable';
12
13
  export * from './specs/aria-specs';
13
14
  export * from './specs/content-model-category-to-tag-names';
15
+ export * from './specs/get-aria';
14
16
  export * from './specs/get-role-spec';
15
17
  export * from './specs/get-spec-by-tag-name';
18
+ export * from './specs/is-nothing-content-model';
16
19
  export * from './specs/is-palpable-elements';
17
20
  export * from './specs/is-void-element';
18
21
  export * from './specs/schema-to-spec';
@@ -21,3 +24,4 @@ export * from './types/aria';
21
24
  export * from './types/attributes';
22
25
  export * from './types/permitted-structures';
23
26
  export * from './utils/resolve-namespace';
27
+ export * from './utils/validateAriaVersion';
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./constant/aria-version"), exports);
4
5
  tslib_1.__exportStar(require("./dom-traverse/accname-computation"), exports);
5
6
  tslib_1.__exportStar(require("./dom-traverse/get-attr-specs"), exports);
6
7
  tslib_1.__exportStar(require("./dom-traverse/get-computed-aria-props"), exports);
@@ -14,8 +15,10 @@ tslib_1.__exportStar(require("./dom-traverse/is-exposed"), exports);
14
15
  tslib_1.__exportStar(require("./dom-traverse/may-be-focusable"), exports);
15
16
  tslib_1.__exportStar(require("./specs/aria-specs"), exports);
16
17
  tslib_1.__exportStar(require("./specs/content-model-category-to-tag-names"), exports);
18
+ tslib_1.__exportStar(require("./specs/get-aria"), exports);
17
19
  tslib_1.__exportStar(require("./specs/get-role-spec"), exports);
18
20
  tslib_1.__exportStar(require("./specs/get-spec-by-tag-name"), exports);
21
+ tslib_1.__exportStar(require("./specs/is-nothing-content-model"), exports);
19
22
  tslib_1.__exportStar(require("./specs/is-palpable-elements"), exports);
20
23
  tslib_1.__exportStar(require("./specs/is-void-element"), exports);
21
24
  tslib_1.__exportStar(require("./specs/schema-to-spec"), exports);
@@ -24,3 +27,4 @@ tslib_1.__exportStar(require("./types/aria"), exports);
24
27
  tslib_1.__exportStar(require("./types/attributes"), exports);
25
28
  tslib_1.__exportStar(require("./types/permitted-structures"), exports);
26
29
  tslib_1.__exportStar(require("./utils/resolve-namespace"), exports);
30
+ tslib_1.__exportStar(require("./utils/validateAriaVersion"), exports);
@@ -1,6 +1,9 @@
1
1
  import type { ARIAVersion, MLMLSpec } from '../types';
2
- export declare function ariaSpecs(specs: Readonly<MLMLSpec>, version: ARIAVersion): {
3
- roles: import("../types").ARIARoleInSchema[];
4
- graphicsRoles: import("../types").ARIARoleInSchema[];
5
- props: import("../types").ARIAProperty[];
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(contentModel: Category, def: MLMLSpec['def']): ReadonlyArray<string>;
3
+ export declare function contentModelCategoryToTagNames(
4
+ contentModel: Category,
5
+ def: MLMLSpec['def'],
6
+ ): ReadonlyArray<string>;
@@ -1,3 +1,10 @@
1
1
  import type { ARIAVersion, Matches, MLMLSpec } from '../types';
2
2
  import type { ARIA } from '../types/aria';
3
- export declare function getARIA(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): Omit<ARIA, ARIAVersion | 'conditions'> | null;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function getARIA(
5
+ specs: MLMLSpec,
6
+ localName: string,
7
+ namespace: string | null,
8
+ version: ARIAVersion,
9
+ matches: Matches,
10
+ ): Omit<ReadonlyDeep<ARIA>, ARIAVersion | 'conditions'> | null;
@@ -21,6 +21,9 @@ function getARIA(specs, localName, namespace, version, matches) {
21
21
  continue;
22
22
  }
23
23
  const condARIA = conditions[cond];
24
+ if (!condARIA) {
25
+ continue;
26
+ }
24
27
  implicitRole = (_a = condARIA.implicitRole) !== null && _a !== void 0 ? _a : implicitRole;
25
28
  permittedRoles = (_b = condARIA.permittedRoles) !== null && _b !== void 0 ? _b : permittedRoles;
26
29
  implicitProperties = (_c = condARIA.implicitProperties) !== null && _c !== void 0 ? _c : implicitProperties;
@@ -49,8 +52,11 @@ function getVersionResolvedARIA(specs, localName, namespace, version) {
49
52
  return null;
50
53
  }
51
54
  aria = (0, resolve_version_1.resolveVersion)(spec, version);
52
- if (aria.permittedRoles) {
53
- aria.permittedRoles = optimizePermittedRoles(aria.permittedRoles);
55
+ if (aria.permittedRoles !== false) {
56
+ aria = {
57
+ ...aria,
58
+ permittedRoles: optimizePermittedRoles(aria.permittedRoles),
59
+ };
54
60
  }
55
61
  cache.set(key, aria);
56
62
  return aria;
@@ -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(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): Attribute[] | null;
3
+ export declare function getAttrSpecs(
4
+ localName: string,
5
+ namespace: NamespaceURI | null,
6
+ schema: MLMLSpec,
7
+ ): readonly Attribute[] | null;
4
8
  type HasName = {
5
- name: string;
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 || undefined);
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 (!catAttrs) {
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(specs: Readonly<MLMLSpec>, localName: string, namespace: string | null, version: ARIAVersion, matches: Matches): import("..").ImplicitRole;
2
+ export declare function getImplicitRole(
3
+ specs: MLMLSpec,
4
+ localName: string,
5
+ namespace: string | null,
6
+ version: ARIAVersion,
7
+ matches: Matches,
8
+ ): import('..').ImplicitRole;
@@ -6,7 +6,13 @@ 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(
10
+ specs: MLMLSpec,
11
+ localName: string,
12
+ namespace: string | null,
13
+ version: ARIAVersion,
14
+ matches: Matches,
15
+ ): readonly {
16
+ readonly name: string;
17
+ readonly deprecated?: boolean;
12
18
  }[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPermittedRoles = void 0;
4
+ const is_plain_object_1 = require("is-plain-object");
4
5
  const merge_array_1 = require("../utils/merge-array");
5
6
  const aria_specs_1 = require("./aria-specs");
6
7
  const get_aria_1 = require("./get-aria");
@@ -26,17 +27,7 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
26
27
  name: role.name,
27
28
  })));
28
29
  }
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')) {
30
+ if (isAAMInfo(permittedRoles)) {
40
31
  if (permittedRoles['core-aam']) {
41
32
  permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, roles
42
33
  .filter(role => !role.isAbstract)
@@ -52,10 +43,23 @@ function getPermittedRoles(specs, localName, namespace, version, matches) {
52
43
  })));
53
44
  }
54
45
  }
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);
46
+ else if (typeof permittedRoles !== 'boolean') {
47
+ permittedRoleList = (0, merge_array_1.mergeArray)(permittedRoleList, permittedRoles.map(role => {
48
+ if (typeof role === 'string') {
49
+ return {
50
+ name: role,
51
+ };
52
+ }
53
+ return role;
54
+ }));
58
55
  }
59
- return permittedRoleList;
56
+ if (implicitRole === false) {
57
+ return permittedRoleList;
58
+ }
59
+ const implicitRoles = implicitRole === 'presentation' || implicitRole === 'none' ? ['none', 'presentation'] : [implicitRole];
60
+ return (0, merge_array_1.mergeArray)(implicitRoles.map(r => ({ name: r })), permittedRoleList);
60
61
  }
61
62
  exports.getPermittedRoles = getPermittedRoles;
63
+ function isAAMInfo(permittedRoles) {
64
+ return (0, is_plain_object_1.isPlainObject)(permittedRoles);
65
+ }
@@ -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(specs: Readonly<MLMLSpec>, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
4
- superClassRoles: ARIARoleInSchema[];
5
- }) | null;
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)) || null);
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);
@@ -1,3 +1,3 @@
1
1
  import type { MLMLSpec } from '../types';
2
2
  import type { Category } from '../types/permitted-structures';
3
- export declare function getSelectorsByContentModelCategory(specs: Readonly<MLMLSpec>, category: Category): ReadonlyArray<string>;
3
+ export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
@@ -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>(specs: Readonly<Pick<ElementSpec, 'name' | K>[]>, localName: string, namespace: string | null): Pick<ElementSpec, "name" | K> | null;
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
- const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace || undefined);
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) || null;
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
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @see https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
3
+ * @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
4
+ */
5
+ export declare function isNothingContentModel(el: Element): boolean;
@@ -0,0 +1,14 @@
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");
5
+ /**
6
+ * @see https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
7
+ * @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
8
+ */
9
+ function isNothingContentModel(
10
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
11
+ el) {
12
+ return (0, is_void_element_1.isVoidElement)(el) || ['iframe', 'template'].includes(el.localName);
13
+ }
14
+ exports.isNothingContentModel = isNothingContentModel;
@@ -1,5 +1,9 @@
1
1
  import type { MLMLSpec } from '../types';
2
- export declare function isPalpableElement(el: Element, specs: Readonly<MLMLSpec>, options?: {
3
- extendsSvg?: boolean;
4
- extendsExposableElements?: boolean;
5
- }): boolean;
2
+ export declare function isPalpableElement(
3
+ el: Element,
4
+ specs: MLMLSpec,
5
+ options?: {
6
+ readonly extendsSvg?: boolean;
7
+ readonly extendsExposableElements?: boolean;
8
+ },
9
+ ): boolean;
@@ -31,11 +31,13 @@ const exposableElementsThatAreNoBelongingAModel = [
31
31
  'thead',
32
32
  'tr',
33
33
  ];
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(',')) || ''];
34
+ function isPalpableElement(
35
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
36
+ el, specs, options) {
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 : ''];
37
39
  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(',')) || '');
40
+ conditions.push((_d = (_c = specs.def['#contentModels']['#SVGRenderable']) === null || _c === void 0 ? void 0 : _c.join(',')) !== null && _d !== void 0 ? _d : '');
39
41
  }
40
42
  if (options === null || options === void 0 ? void 0 : options.extendsExposableElements /* default false */) {
41
43
  conditions.push(exposableElementsThatAreNoBelongingAModel.join(','));
@@ -19,7 +19,9 @@ const voidElements = [
19
19
  'track',
20
20
  'wbr',
21
21
  ];
22
- function isVoidElement(el) {
22
+ function isVoidElement(
23
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
24
+ el) {
23
25
  return voidElements.includes(el.localName);
24
26
  }
25
27
  exports.isVoidElement = isVoidElement;
@@ -1,3 +1,7 @@
1
1
  import type { ARIAVersion } from '../types';
2
2
  import type { ARIA } from '../types/aria';
3
- export declare function resolveVersion(aria: ARIA, version: ARIAVersion): Omit<ARIA, ARIAVersion>;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function resolveVersion(
5
+ aria: ReadonlyDeep<ARIA>,
6
+ version: ARIAVersion,
7
+ ): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
@@ -7,7 +7,7 @@ function resolveVersion(aria, version) {
7
7
  const permittedRoles = (_d = (_c = aria[version]) === null || _c === void 0 ? void 0 : _c.permittedRoles) !== null && _d !== void 0 ? _d : aria.permittedRoles;
8
8
  const implicitProperties = (_f = (_e = aria[version]) === null || _e === void 0 ? void 0 : _e.implicitProperties) !== null && _f !== void 0 ? _f : aria.implicitProperties;
9
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;
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
11
  const conditions = (_m = (_l = aria[version]) === null || _l === void 0 ? void 0 : _l.conditions) !== null && _m !== void 0 ? _m : aria.conditions;
12
12
  return {
13
13
  implicitRole,
@@ -2,12 +2,12 @@ import type { ElementSpec, ExtendedSpec, MLMLSpec } from '../types';
2
2
  /**
3
3
  * Merging HTML-spec schema and extended spec schemas
4
4
  *
5
- * Ex: `@markuplint/html-spec` + `{ specs: ["@markuplint/vue-spec"] }` in configure files.
5
+ * Ex: `@markuplint/html-spec` + `{ specs: { "\\.vue$": "@markuplint/vue-spec" } }` in configure files.
6
6
  *
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').Cites;
11
+ def: import('../types').SpecDefs;
12
+ specs: readonly ElementSpec[];
13
13
  };
@@ -5,12 +5,12 @@ const merge_array_1 = require("../utils/merge-array");
5
5
  /**
6
6
  * Merging HTML-spec schema and extended spec schemas
7
7
  *
8
- * Ex: `@markuplint/html-spec` + `{ specs: ["@markuplint/vue-spec"] }` in configure files.
8
+ * Ex: `@markuplint/html-spec` + `{ specs: { "\\.vue$": "@markuplint/vue-spec" } }` in configure files.
9
9
  *
10
10
  * @param schemas `MLDocument.schemas`
11
11
  */
12
12
  function schemaToSpec(schemas) {
13
- var _a, _b, _c;
13
+ var _a, _b, _c, _d, _e;
14
14
  const [main, ...extendedSpecs] = schemas;
15
15
  const result = { ...main };
16
16
  for (const extendedSpec of extendedSpecs) {
@@ -18,37 +18,48 @@ function schemaToSpec(schemas) {
18
18
  result.cites = [...result.cites, ...extendedSpec.cites];
19
19
  }
20
20
  if (extendedSpec.def) {
21
+ const def = { ...result.def };
21
22
  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']) || {}),
23
+ const gAttrs = { ...def['#globalAttrs'] };
24
+ gAttrs['#HTMLGlobalAttrs'] = {
25
+ ...((_c = (_b = def['#globalAttrs']) === null || _b === void 0 ? void 0 : _b['#HTMLGlobalAttrs']) !== null && _c !== void 0 ? _c : {}),
26
+ ...((_e = (_d = extendedSpec.def['#globalAttrs']) === null || _d === void 0 ? void 0 : _d['#extends']) !== null && _e !== void 0 ? _e : {}),
25
27
  };
28
+ def['#globalAttrs'] = gAttrs;
26
29
  }
27
30
  if (extendedSpec.def['#aria']) {
28
- result.def['#aria'] = {
31
+ def['#aria'] = {
29
32
  '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),
33
+ roles: (0, merge_array_1.mergeArray)(def['#aria']['1.1'].roles, extendedSpec.def['#aria']['1.1'].roles),
34
+ props: (0, merge_array_1.mergeArray)(def['#aria']['1.1'].props, extendedSpec.def['#aria']['1.1'].props),
35
+ graphicsRoles: (0, merge_array_1.mergeArray)(def['#aria']['1.1'].graphicsRoles, extendedSpec.def['#aria']['1.1'].graphicsRoles),
33
36
  },
34
37
  '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),
38
+ roles: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].roles, extendedSpec.def['#aria']['1.2'].roles),
39
+ props: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].props, extendedSpec.def['#aria']['1.2'].props),
40
+ graphicsRoles: (0, merge_array_1.mergeArray)(def['#aria']['1.2'].graphicsRoles, extendedSpec.def['#aria']['1.2'].graphicsRoles),
41
+ },
42
+ '1.3': {
43
+ roles: (0, merge_array_1.mergeArray)(def['#aria']['1.3'].roles, extendedSpec.def['#aria']['1.3'].roles),
44
+ props: (0, merge_array_1.mergeArray)(def['#aria']['1.3'].props, extendedSpec.def['#aria']['1.3'].props),
45
+ graphicsRoles: (0, merge_array_1.mergeArray)(def['#aria']['1.3'].graphicsRoles, extendedSpec.def['#aria']['1.3'].graphicsRoles),
38
46
  },
39
47
  };
40
48
  }
41
49
  if (extendedSpec.def['#contentModels']) {
50
+ const models = { ...def['#contentModels'] };
42
51
  const keys = new Set([
43
- ...Object.keys(result.def['#contentModels']),
52
+ ...Object.keys(def['#contentModels']),
44
53
  ...Object.keys(extendedSpec.def['#contentModels']),
45
54
  ]);
46
55
  for (const modelName of keys) {
47
- const mainModel = result.def['#contentModels'][modelName];
56
+ const mainModel = def['#contentModels'][modelName];
48
57
  const exModel = extendedSpec.def['#contentModels'][modelName];
49
- result.def['#contentModels'][modelName] = [...(mainModel || []), ...(exModel || [])];
58
+ models[modelName] = [...(mainModel !== null && mainModel !== void 0 ? mainModel : []), ...(exModel !== null && exModel !== void 0 ? exModel : [])];
50
59
  }
60
+ def['#contentModels'] = models;
51
61
  }
62
+ result.def = def;
52
63
  }
53
64
  if (extendedSpec.specs) {
54
65
  const exSpecs = extendedSpec.specs.slice();
@@ -66,10 +77,10 @@ function schemaToSpec(schemas) {
66
77
  ...exSpec,
67
78
  globalAttrs: {
68
79
  ...elSpec.globalAttrs,
69
- ...exSpec.globalAttrs,
80
+ ...exSpec === null || exSpec === void 0 ? void 0 : exSpec.globalAttrs,
70
81
  },
71
- attributes: mergeAttrSpec(elSpec.attributes, exSpec.attributes),
72
- categories: (0, merge_array_1.mergeArray)(elSpec.categories, exSpec.categories),
82
+ attributes: mergeAttrSpec(elSpec.attributes, exSpec === null || exSpec === void 0 ? void 0 : exSpec.attributes),
83
+ categories: (0, merge_array_1.mergeArray)(elSpec.categories, exSpec === null || exSpec === void 0 ? void 0 : exSpec.categories),
73
84
  });
74
85
  }
75
86
  result.specs = specs;