@markuplint/ml-spec 3.4.0 → 3.5.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.
Files changed (49) hide show
  1. package/lib/dom-traverse/accname-computation.js +3 -1
  2. package/lib/dom-traverse/get-attr-specs.d.ts +1 -1
  3. package/lib/dom-traverse/get-attr-specs.js +3 -1
  4. package/lib/dom-traverse/get-computed-aria-props.d.ts +6 -6
  5. package/lib/dom-traverse/get-computed-aria-props.js +3 -1
  6. package/lib/dom-traverse/get-computed-role.d.ts +1 -1
  7. package/lib/dom-traverse/get-computed-role.js +10 -4
  8. package/lib/dom-traverse/get-content-model.d.ts +3 -5
  9. package/lib/dom-traverse/get-content-model.js +3 -1
  10. package/lib/dom-traverse/get-explicit-role.js +6 -2
  11. package/lib/dom-traverse/get-implicit-role.d.ts +2 -6
  12. package/lib/dom-traverse/get-implicit-role.js +6 -2
  13. package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +4 -10
  14. package/lib/dom-traverse/get-non-presentational-ancestor.js +3 -1
  15. package/lib/dom-traverse/get-permitted-roles.d.ts +3 -7
  16. package/lib/dom-traverse/get-permitted-roles.js +3 -1
  17. package/lib/dom-traverse/get-spec.d.ts +1 -4
  18. package/lib/dom-traverse/get-spec.js +3 -1
  19. package/lib/dom-traverse/has-required-owned-elements.d.ts +2 -7
  20. package/lib/dom-traverse/has-required-owned-elements.js +14 -8
  21. package/lib/dom-traverse/is-exposed.d.ts +1 -1
  22. package/lib/dom-traverse/is-exposed.js +18 -6
  23. package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
  24. package/lib/dom-traverse/may-be-focusable.js +3 -1
  25. package/lib/specs/aria-specs.d.ts +4 -7
  26. package/lib/specs/content-model-category-to-tag-names.d.ts +1 -4
  27. package/lib/specs/get-aria.d.ts +2 -7
  28. package/lib/specs/get-aria.js +4 -1
  29. package/lib/specs/get-attr-specs.d.ts +2 -6
  30. package/lib/specs/get-implicit-role.d.ts +1 -7
  31. package/lib/specs/get-permitted-roles.d.ts +3 -9
  32. package/lib/specs/get-permitted-roles.js +15 -11
  33. package/lib/specs/get-role-spec.d.ts +3 -10
  34. package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -4
  35. package/lib/specs/get-spec-by-tag-name.d.ts +1 -5
  36. package/lib/specs/is-nothing-content-model.js +3 -1
  37. package/lib/specs/is-palpable-elements.d.ts +4 -8
  38. package/lib/specs/is-palpable-elements.js +3 -1
  39. package/lib/specs/is-void-element.js +3 -1
  40. package/lib/specs/resolve-version.d.ts +2 -1
  41. package/lib/specs/schema-to-spec.d.ts +3 -3
  42. package/lib/specs/schema-to-spec.js +20 -14
  43. package/lib/types/aria.d.ts +115 -128
  44. package/lib/types/attributes.d.ts +110 -1490
  45. package/lib/types/index.d.ts +147 -176
  46. package/lib/types/permitted-structures.d.ts +35 -74
  47. package/lib/utils/merge-array.d.ts +4 -6
  48. package/lib/utils/resolve-namespace.d.ts +4 -4
  49. package/package.json +8 -6
@@ -31,7 +31,9 @@ const exposableElementsThatAreNoBelongingAModel = [
31
31
  'thead',
32
32
  'tr',
33
33
  ];
34
- function isPalpableElement(el, specs, options) {
34
+ function isPalpableElement(
35
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
36
+ el, specs, options) {
35
37
  var _a, _b;
36
38
  const conditions = [((_a = specs.def['#contentModels']['#palpable']) === null || _a === void 0 ? void 0 : _a.join(',')) || ''];
37
39
  if ((options === null || options === void 0 ? void 0 : options.extendsSvg) !== false /* default true */) {
@@ -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,4 @@
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(aria: ReadonlyDeep<ARIA>, version: ARIAVersion): 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
- 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
  };
@@ -10,7 +10,7 @@ const merge_array_1 = require("../utils/merge-array");
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,43 @@ 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),
38
41
  },
39
42
  };
40
43
  }
41
44
  if (extendedSpec.def['#contentModels']) {
45
+ const models = { ...def['#contentModels'] };
42
46
  const keys = new Set([
43
- ...Object.keys(result.def['#contentModels']),
47
+ ...Object.keys(def['#contentModels']),
44
48
  ...Object.keys(extendedSpec.def['#contentModels']),
45
49
  ]);
46
50
  for (const modelName of keys) {
47
- const mainModel = result.def['#contentModels'][modelName];
51
+ const mainModel = def['#contentModels'][modelName];
48
52
  const exModel = extendedSpec.def['#contentModels'][modelName];
49
- result.def['#contentModels'][modelName] = [...(mainModel || []), ...(exModel || [])];
53
+ models[modelName] = [...(mainModel !== null && mainModel !== void 0 ? mainModel : []), ...(exModel !== null && exModel !== void 0 ? exModel : [])];
50
54
  }
55
+ def['#contentModels'] = models;
51
56
  }
57
+ result.def = def;
52
58
  }
53
59
  if (extendedSpec.specs) {
54
60
  const exSpecs = extendedSpec.specs.slice();
@@ -10,141 +10,128 @@ export type ImplicitRole = false | string;
10
10
  /**
11
11
  * If `true`, this mean is "Any". If `false`, this mean is "No".
12
12
  */
13
- export type PermittedRoles =
14
- | boolean
15
- | (
16
- | string
17
- | {
18
- name: string;
19
- deprecated?: true;
20
- [k: string]: unknown;
21
- }
22
- )[]
23
- | {
24
- 'core-aam'?: true;
25
- 'graphics-aam'?: true;
26
- };
13
+ export type PermittedRoles = boolean | (string | {
14
+ name: string;
15
+ deprecated?: true;
16
+ [k: string]: unknown;
17
+ })[] | PermittedARIAAAMInfo;
27
18
  /**
28
19
  * If set false:
29
20
  * > No role or aria-* attributes
30
21
  */
31
- export type PermittedARIAProperties =
32
- | false
33
- | {
34
- global?: true;
35
- /**
36
- * Set true if the spec says "and any aria-* attributes applicable to the allowed roles."
37
- */
38
- role?: true | string | [string, ...string[]];
39
- /**
40
- * @minItems 1
41
- */
42
- only?: [
43
- (
44
- | string
45
- | {
46
- name: string;
47
- value?: string;
48
- }
49
- ),
50
- ...(
51
- | string
52
- | {
53
- name: string;
54
- value?: string;
55
- }
56
- )[],
57
- ];
58
- /**
59
- * @minItems 1
60
- */
61
- without?: [
62
- {
63
- type: 'not-recommended' | 'should-not' | 'must-not';
64
- name: string;
65
- value?: string;
66
- alt?: {
67
- method: 'remove-attr' | 'set-attr';
68
- target: string;
69
- };
70
- },
71
- ...{
72
- type: 'not-recommended' | 'should-not' | 'must-not';
73
- name: string;
74
- value?: string;
75
- alt?: {
76
- method: 'remove-attr' | 'set-attr';
77
- target: string;
78
- };
79
- }[],
80
- ];
81
- };
22
+ export type PermittedARIAProperties = false | {
23
+ global?: true;
24
+ /**
25
+ * Set true if the spec says "and any aria-* attributes applicable to the allowed roles."
26
+ */
27
+ role?: true | string | [string, ...string[]];
28
+ /**
29
+ * @minItems 1
30
+ */
31
+ only?: [
32
+ (string | {
33
+ name: string;
34
+ value?: string;
35
+ }),
36
+ ...(string | {
37
+ name: string;
38
+ value?: string;
39
+ })[]
40
+ ];
41
+ /**
42
+ * @minItems 1
43
+ */
44
+ without?: [
45
+ {
46
+ type: 'not-recommended' | 'should-not' | 'must-not';
47
+ name: string;
48
+ value?: string;
49
+ alt?: {
50
+ method: 'remove-attr' | 'set-attr';
51
+ target: string;
52
+ };
53
+ },
54
+ ...{
55
+ type: 'not-recommended' | 'should-not' | 'must-not';
56
+ name: string;
57
+ value?: string;
58
+ alt?: {
59
+ method: 'remove-attr' | 'set-attr';
60
+ target: string;
61
+ };
62
+ }[]
63
+ ];
64
+ };
82
65
  export interface AriaSchema {
83
- _?: ARIA;
84
- [k: string]: unknown;
66
+ _?: ARIA;
67
+ [k: string]: unknown;
85
68
  }
86
69
  export interface ARIA {
87
- implicitRole: ImplicitRole;
88
- permittedRoles: PermittedRoles;
89
- namingProhibited?: true;
90
- implicitProperties?: ImplicitProperties;
91
- properties?: PermittedARIAProperties;
92
- conditions?: {
93
- /**
94
- * This interface was referenced by `undefined`'s JSON-Schema definition
95
- * via the `patternProperty` ".+".
96
- */
97
- [k: string]: {
98
- implicitRole?: ImplicitRole;
99
- permittedRoles?: PermittedRoles;
100
- namingProhibited?: true;
101
- implicitProperties?: ImplicitProperties;
102
- properties?: PermittedARIAProperties;
103
- };
104
- };
105
- '1.2'?: {
106
- implicitRole?: ImplicitRole;
107
- permittedRoles?: PermittedRoles;
108
- namingProhibited?: true;
109
- implicitProperties?: ImplicitProperties;
110
- properties?: PermittedARIAProperties;
111
- conditions?: {
112
- /**
113
- * This interface was referenced by `undefined`'s JSON-Schema definition
114
- * via the `patternProperty` ".+".
115
- */
116
- [k: string]: {
117
- implicitRole?: ImplicitRole;
118
- permittedRoles?: PermittedRoles;
119
- namingProhibited?: true;
120
- implicitProperties?: ImplicitProperties;
121
- properties?: PermittedARIAProperties;
122
- };
123
- };
124
- };
125
- '1.1'?: {
126
- implicitRole?: ImplicitRole;
127
- permittedRoles?: PermittedRoles;
128
- implicitProperties?: ImplicitProperties;
129
- properties?: PermittedARIAProperties;
130
- conditions?: {
131
- /**
132
- * This interface was referenced by `undefined`'s JSON-Schema definition
133
- * via the `patternProperty` ".+".
134
- */
135
- [k: string]: {
136
- implicitRole?: ImplicitRole;
137
- permittedRoles?: PermittedRoles;
138
- implicitProperties?: ImplicitProperties;
139
- properties?: PermittedARIAProperties;
140
- };
141
- };
142
- };
70
+ implicitRole: ImplicitRole;
71
+ permittedRoles: PermittedRoles;
72
+ namingProhibited?: true;
73
+ implicitProperties?: ImplicitProperties;
74
+ properties?: PermittedARIAProperties;
75
+ conditions?: {
76
+ /**
77
+ * This interface was referenced by `undefined`'s JSON-Schema definition
78
+ * via the `patternProperty` ".+".
79
+ */
80
+ [k: string]: {
81
+ implicitRole?: ImplicitRole;
82
+ permittedRoles?: PermittedRoles;
83
+ namingProhibited?: true;
84
+ implicitProperties?: ImplicitProperties;
85
+ properties?: PermittedARIAProperties;
86
+ };
87
+ };
88
+ '1.2'?: {
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
+ };
108
+ '1.1'?: {
109
+ implicitRole?: ImplicitRole;
110
+ permittedRoles?: PermittedRoles;
111
+ implicitProperties?: ImplicitProperties;
112
+ properties?: PermittedARIAProperties;
113
+ conditions?: {
114
+ /**
115
+ * This interface was referenced by `undefined`'s JSON-Schema definition
116
+ * via the `patternProperty` ".+".
117
+ */
118
+ [k: string]: {
119
+ implicitRole?: ImplicitRole;
120
+ permittedRoles?: PermittedRoles;
121
+ implicitProperties?: ImplicitProperties;
122
+ properties?: PermittedARIAProperties;
123
+ };
124
+ };
125
+ };
126
+ }
127
+ export interface PermittedARIAAAMInfo {
128
+ 'core-aam'?: true;
129
+ 'graphics-aam'?: true;
143
130
  }
144
131
  export interface ImplicitProperties {
145
- /**
146
- * This interface was referenced by `ImplicitProperties`'s JSON-Schema definition
147
- * via the `patternProperty` "^aria-.+".
148
- */
149
- [k: string]: string;
132
+ /**
133
+ * This interface was referenced by `ImplicitProperties`'s JSON-Schema definition
134
+ * via the `patternProperty` "^aria-.+".
135
+ */
136
+ [k: string]: string;
150
137
  }