@markuplint/ml-spec 3.0.0-alpha.2 → 3.0.0-alpha.27

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 (74) hide show
  1. package/README.md +8 -3
  2. package/lib/dom-traverse/get-computed-aria-props.d.ts +12 -0
  3. package/lib/dom-traverse/get-computed-aria-props.js +106 -0
  4. package/lib/dom-traverse/get-explicit-role.js +1 -1
  5. package/lib/dom-traverse/is-exposed.d.ts +11 -0
  6. package/lib/dom-traverse/is-exposed.js +181 -0
  7. package/lib/index.d.ts +5 -0
  8. package/lib/index.js +5 -0
  9. package/lib/specs/get-attr-specs.d.ts +1 -1
  10. package/lib/specs/is-nothing-content-model.d.ts +5 -0
  11. package/lib/specs/is-nothing-content-model.js +12 -0
  12. package/lib/specs/is-palpable-elements.d.ts +5 -0
  13. package/lib/specs/is-palpable-elements.js +47 -0
  14. package/lib/specs/is-void-element.d.ts +1 -0
  15. package/lib/specs/is-void-element.js +25 -0
  16. package/lib/specs/schema-to-spec.d.ts +1 -1
  17. package/lib/specs/schema-to-spec.js +1 -1
  18. package/lib/types/aria.d.ts +3 -3
  19. package/lib/types/attributes.d.ts +2 -2
  20. package/lib/types/index.d.ts +21 -21
  21. package/lib/types/permitted-structres.d.ts +4 -4
  22. package/lib/types/permitted-structures.d.ts +4 -4
  23. package/lib/utils/merge-array.d.ts +1 -1
  24. package/lib/utils/resolve-namespace.d.ts +1 -1
  25. package/package.json +6 -6
  26. package/schemas/aria.schema.json +0 -258
  27. package/schemas/attributes.schema.json +0 -204
  28. package/schemas/content-models.schema.json +0 -200
  29. package/schemas/element.schema.json +0 -11
  30. package/schemas/global-attributes.schema.json +0 -761
  31. package/src/dom-traverse/accname-computation.spec.ts +0 -69
  32. package/src/dom-traverse/accname-computation.ts +0 -5
  33. package/src/dom-traverse/get-attr-specs.ts +0 -8
  34. package/src/dom-traverse/get-computed-role.spec.ts +0 -134
  35. package/src/dom-traverse/get-computed-role.ts +0 -181
  36. package/src/dom-traverse/get-content-model.ts +0 -32
  37. package/src/dom-traverse/get-explicit-role.ts +0 -112
  38. package/src/dom-traverse/get-implicit-role.ts +0 -36
  39. package/src/dom-traverse/get-non-presentational-ancestor.ts +0 -20
  40. package/src/dom-traverse/get-permitted-roles.ts +0 -7
  41. package/src/dom-traverse/get-spec.ts +0 -7
  42. package/src/dom-traverse/has-required-owned-elements.spec.ts +0 -36
  43. package/src/dom-traverse/has-required-owned-elements.ts +0 -85
  44. package/src/dom-traverse/may-be-focusable.ts +0 -21
  45. package/src/index.ts +0 -19
  46. package/src/specs/aria-specs.ts +0 -6
  47. package/src/specs/content-model-category-to-tag-names.ts +0 -15
  48. package/src/specs/get-aria.ts +0 -85
  49. package/src/specs/get-attr-specs.spec.ts +0 -47
  50. package/src/specs/get-attr-specs.ts +0 -116
  51. package/src/specs/get-implicit-role.spec.ts +0 -81
  52. package/src/specs/get-implicit-role.ts +0 -17
  53. package/src/specs/get-permitted-roles.spec.ts +0 -420
  54. package/src/specs/get-permitted-roles.ts +0 -87
  55. package/src/specs/get-role-spec.spec.ts +0 -67
  56. package/src/specs/get-role-spec.ts +0 -72
  57. package/src/specs/get-selectors-by-content-model-category.ts +0 -10
  58. package/src/specs/get-spec-by-tag-name.spec.ts +0 -68
  59. package/src/specs/get-spec-by-tag-name.ts +0 -20
  60. package/src/specs/is-presentational.ts +0 -6
  61. package/src/specs/resolve-version.ts +0 -20
  62. package/src/specs/schema-to-spec.spec.ts +0 -39
  63. package/src/specs/schema-to-spec.ts +0 -103
  64. package/src/types/aria.ts +0 -153
  65. package/src/types/attributes.ts +0 -1473
  66. package/src/types/index.ts +0 -255
  67. package/src/types/permitted-structres.ts +0 -101
  68. package/src/types/permitted-structures.ts +0 -97
  69. package/src/utils/get-ns.ts +0 -18
  70. package/src/utils/merge-array.ts +0 -35
  71. package/src/utils/resolve-namespace.spec.ts +0 -37
  72. package/src/utils/resolve-namespace.ts +0 -40
  73. package/tsconfig.test.json +0 -3
  74. package/tsconfig.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -1,13 +1,18 @@
1
1
  # @markuplint/ml-spec
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40markuplint%2Fml-spec.svg)](https://www.npmjs.com/package/@markuplint/ml-spec)
4
- [![Build Status](https://travis-ci.org/markuplint/markuplint.svg?branch=main)](https://travis-ci.org/markuplint/markuplint)
5
- [![Coverage Status](https://coveralls.io/repos/github/markuplint/markuplint/badge.svg?branch=main)](https://coveralls.io/github/markuplint/markuplint?branch=main)
6
4
 
7
5
  ## Install
8
6
 
9
- ```sh
7
+ [`markuplint`](https://www.npmjs.com/package/markuplint) package includes this package.
8
+
9
+ <details>
10
+ <summary>If you are installing purposely, how below:</summary>
11
+
12
+ ```shell
10
13
  $ npm install @markuplint/ml-spec
11
14
 
12
15
  $ yarn add @markuplint/ml-spec
13
16
  ```
17
+
18
+ </details>
@@ -0,0 +1,12 @@
1
+ import type { ARIAVersion, MLMLSpec } from '../types';
2
+ type ARIAProps = Record<string, ARIAProp>;
3
+ type ARIAProp = {
4
+ name: string;
5
+ value: string | undefined;
6
+ required: boolean;
7
+ deprecated: boolean;
8
+ from: ARIAPropReferenceType;
9
+ };
10
+ type ARIAPropReferenceType = 'default' | 'html-attr' | 'aria-attr';
11
+ export declare function getComputedAriaProps(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ARIAProps;
12
+ export {};
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getComputedAriaProps = void 0;
4
+ const aria_specs_1 = require("../specs/aria-specs");
5
+ const get_computed_role_1 = require("./get-computed-role");
6
+ function getComputedAriaProps(specs, el, version) {
7
+ const ariaSpecs = (0, aria_specs_1.ariaSpecs)(specs, version);
8
+ const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
9
+ if (!role) {
10
+ return {};
11
+ }
12
+ const props = {};
13
+ role.ownedProperties.forEach(ownedProp => {
14
+ var _a;
15
+ const spec = ariaSpecs.props.find(propSpec => propSpec.name === ownedProp.name);
16
+ if (!spec) {
17
+ return;
18
+ }
19
+ if (el.hasAttribute(spec.name)) {
20
+ const attrValue = el.getAttribute(spec.name);
21
+ if (attrValue && isValidAriaValue(spec, role.name, attrValue, spec.enum)) {
22
+ props[ownedProp.name] = {
23
+ name: ownedProp.name,
24
+ value: attrValue,
25
+ deprecated: !!spec.deprecated,
26
+ required: !!ownedProp.required,
27
+ from: 'aria-attr',
28
+ };
29
+ return;
30
+ }
31
+ }
32
+ const equivalentHtmlAttr = (_a = spec.equivalentHtmlAttrs) === null || _a === void 0 ? void 0 : _a[0];
33
+ if (equivalentHtmlAttr && el.hasAttribute(equivalentHtmlAttr.htmlAttrName)) {
34
+ const value = equivalentHtmlAttr.value === null
35
+ ? el.getAttribute(equivalentHtmlAttr.htmlAttrName)
36
+ : equivalentHtmlAttr.value;
37
+ if (value != null) {
38
+ props[ownedProp.name] = {
39
+ name: ownedProp.name,
40
+ value,
41
+ deprecated: !!spec.deprecated,
42
+ required: !!ownedProp.required,
43
+ from: 'html-attr',
44
+ };
45
+ return;
46
+ }
47
+ }
48
+ let defaultValue = spec.defaultValue;
49
+ /**
50
+ * @see https://www.w3.org/TR/html-aria/#el-h1-h6
51
+ */
52
+ if (ownedProp.name === 'aria-level' && /^H[1-6]$/.test(el.nodeName)) {
53
+ defaultValue = el.nodeName.replace('H', '');
54
+ }
55
+ props[ownedProp.name] = {
56
+ name: ownedProp.name,
57
+ value: defaultValue,
58
+ deprecated: !!spec.deprecated,
59
+ required: !!ownedProp.required,
60
+ from: 'default',
61
+ };
62
+ });
63
+ return props;
64
+ }
65
+ exports.getComputedAriaProps = getComputedAriaProps;
66
+ function isValidAriaValue(spec, role, value, enumList) {
67
+ let type = spec.value;
68
+ if (spec.conditionalValue) {
69
+ for (const cond of spec.conditionalValue) {
70
+ if (cond.role.includes(role)) {
71
+ type = cond.value;
72
+ }
73
+ }
74
+ }
75
+ value = (value !== null && value !== void 0 ? value : '').trim();
76
+ switch (type) {
77
+ case 'string': {
78
+ return true;
79
+ }
80
+ case 'ID reference':
81
+ case 'ID reference list':
82
+ case 'URI': {
83
+ return !!value;
84
+ }
85
+ case 'integer':
86
+ case 'number': {
87
+ return !isNaN(parseFloat(value));
88
+ }
89
+ case 'token':
90
+ case 'token list': {
91
+ if (!enumList.length) {
92
+ throw new Error('Need an enum list in token and token list types');
93
+ }
94
+ return enumList.includes(value.toLowerCase());
95
+ }
96
+ case 'tristate': {
97
+ return ['true', 'false', 'mixed'].includes(value.toLowerCase());
98
+ }
99
+ case 'true/false': {
100
+ return ['true', 'false'].includes(value.toLowerCase());
101
+ }
102
+ case 'true/false/undefined': {
103
+ return ['true', 'false', 'undefined'].includes(value.toLowerCase());
104
+ }
105
+ }
106
+ }
@@ -13,7 +13,7 @@ function getExplicitRole(specs, el, version) {
13
13
  /**
14
14
  * Resolve from values and **Handling Author Errors**
15
15
  *
16
- * @see https://w3c.github.io/aria/#document-handling_author-errors_roles
16
+ * @see https://w3c.github.io/aria/#document-handling_author-errors
17
17
  */
18
18
  for (const roleName of roleNames) {
19
19
  const spec = (0, get_role_spec_1.getRoleSpec)(specs, roleName, namespaceURI, version);
@@ -0,0 +1,11 @@
1
+ import type { ARIAVersion, MLMLSpec } from '../types';
2
+ /**
3
+ * Detect including/excluding from the Accessibility Tree
4
+ *
5
+ * @see https://www.w3.org/TR/wai-aria-1.2/#accessibility_tree
6
+ *
7
+ * @param specs
8
+ * @param el
9
+ * @param version
10
+ */
11
+ export declare function isExposed(el: Element, specs: Readonly<MLMLSpec>, version: ARIAVersion): boolean;
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExposed = void 0;
4
+ const aria_specs_1 = require("../specs/aria-specs");
5
+ const is_palpable_elements_1 = require("../specs/is-palpable-elements");
6
+ const is_presentational_1 = require("../specs/is-presentational");
7
+ const get_computed_role_1 = require("./get-computed-role");
8
+ /**
9
+ * Detect including/excluding from the Accessibility Tree
10
+ *
11
+ * @see https://www.w3.org/TR/wai-aria-1.2/#accessibility_tree
12
+ *
13
+ * @param specs
14
+ * @param el
15
+ * @param version
16
+ */
17
+ function isExposed(el, specs, version) {
18
+ // According to WAI-ARIA
19
+ if (isExcluding(el, specs, version)) {
20
+ return false;
21
+ }
22
+ // According to HTML and SVG Specs with **the author's interpretation**
23
+ {
24
+ if (!(0, is_palpable_elements_1.isPalpableElement)(el, specs, { extendsSvg: true, extendsExposableElements: true })) {
25
+ return false;
26
+ }
27
+ }
28
+ // According to WAI-ARIA
29
+ {
30
+ const exposable = isIncluding(el, specs, version);
31
+ if (exposable) {
32
+ return true;
33
+ }
34
+ }
35
+ // Default
36
+ return true;
37
+ }
38
+ exports.isExposed = isExposed;
39
+ /**
40
+ * Excluding Elements from the Accessibility Tree
41
+ *
42
+ * @see https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
43
+ *
44
+ * @param specs
45
+ * @param el
46
+ * @param version
47
+ */
48
+ function isExcluding(el, specs, version) {
49
+ /**
50
+ * The following elements are not exposed via the accessibility API and
51
+ * user agents MUST NOT include them in the accessibility tree:
52
+ * - Elements, including their descendent elements,
53
+ * that have host language semantics specifying
54
+ * that the element is not displayed, such as CSS display:none,
55
+ * visibility:hidden, or the HTML hidden attribute.
56
+ */
57
+ {
58
+ let currentEl = el;
59
+ while (currentEl) {
60
+ if (hasDisplayNodeOrVisibilityHidden(currentEl) || currentEl.hasAttribute('hidden')) {
61
+ return true;
62
+ }
63
+ currentEl = currentEl.parentElement;
64
+ }
65
+ }
66
+ /**
67
+ * - Elements with none or presentation as the first role in the role attribute.
68
+ * However, their exclusion is conditional. In addition,
69
+ * the element's descendants and text content are generally included.
70
+ * These exceptions and conditions are documented in the presentation (role)
71
+ * section.
72
+ */
73
+ if ((0, is_presentational_1.isPresentational)((el.getAttribute('role') || '').split(/\s+/)[0])) {
74
+ return true;
75
+ }
76
+ /**
77
+ * If not already excluded from the accessibility tree per the above rules,
78
+ * user agents SHOULD NOT include the following elements
79
+ * in the accessibility tree:
80
+ * - Elements, including their descendants, that have aria-hidden set to true.
81
+ * In other words, aria-hidden="true" on a parent overrides aria-hidden="false"
82
+ * on descendants.
83
+ */
84
+ {
85
+ let currentEl = el;
86
+ while (currentEl) {
87
+ if (currentEl.getAttribute('aria-hidden') === 'true') {
88
+ return true;
89
+ }
90
+ currentEl = currentEl.parentElement;
91
+ }
92
+ }
93
+ /**
94
+ * - Any descendants of elements that have the characteristic
95
+ * "Children Presentational: True" unless the descendant
96
+ * is not allowed to be presentational because it meets one of
97
+ * the conditions for exception described in
98
+ * Presentational Roles Conflict Resolution.
99
+ * However, the text content of any excluded descendants is included.
100
+ */
101
+ {
102
+ let currentEl = el.parentElement;
103
+ while (currentEl) {
104
+ const { role } = (0, get_computed_role_1.getComputedRole)(specs, currentEl, version);
105
+ if (role === null || role === void 0 ? void 0 : role.childrenPresentational) {
106
+ return true;
107
+ }
108
+ currentEl = currentEl.parentElement;
109
+ }
110
+ }
111
+ return false;
112
+ }
113
+ /**
114
+ * Including Elements in the Accessibility Tree
115
+ *
116
+ * If not excluded from or marked as hidden in the accessibility tree
117
+ * per the rules above in Excluding Elements in the Accessibility Tree,
118
+ * user agents MUST provide an accessible object in the accessibility tree
119
+ * for DOM elements that meet any of the following criteria:
120
+ *
121
+ * @see https://www.w3.org/TR/wai-aria-1.2/#tree_inclusion
122
+ *
123
+ * @param specs
124
+ * @param el
125
+ * @param version
126
+ */
127
+ function isIncluding(el, specs, version) {
128
+ /**
129
+ * > **meet any** of the following criteria:
130
+ */
131
+ const results = [];
132
+ /**
133
+ * Elements that are not hidden and may fire an accessibility API event,
134
+ * including:
135
+ * - Elements that are currently focused, even if the element or one of
136
+ * its ancestor elements has its aria-hidden attribute set to true.
137
+ */
138
+ // 🚫 Can't detect the element is focused.
139
+ // results.push(true);
140
+ /**
141
+ * - Elements that are a valid target of an aria-activedescendant attribute.
142
+ */
143
+ // TODO: Compute aria-activedescendant.
144
+ // results.push(true);
145
+ /**
146
+ * Elements that have an explicit role or a global WAI-ARIA attribute and
147
+ * do not have aria-hidden set to true.
148
+ * (See Excluding Elements in the Accessibility Tree for
149
+ * additional guidance on aria-hidden.)
150
+ */
151
+ if (el.getAttribute('aria-hidden') !== 'true') {
152
+ const globalAria = (0, aria_specs_1.ariaSpecs)(specs, version).props.filter(prop => prop.isGlobal);
153
+ const { role } = (0, get_computed_role_1.getComputedRole)(specs, el, version);
154
+ // Has an explicit role
155
+ if (role && !role.isImplicit) {
156
+ results.push(true);
157
+ }
158
+ // Has a global WAI-ARIA attribute
159
+ for (const attr of Array.from(el.attributes)) {
160
+ if (globalAria.some(aria => aria.name === attr.localName)) {
161
+ results.push(true);
162
+ break;
163
+ }
164
+ }
165
+ }
166
+ /**
167
+ * Elements that are not hidden and have an ID that is referenced
168
+ * by another element via a WAI-ARIA property.
169
+ */
170
+ // TODO: Compute refering ID.
171
+ // results.push(true);
172
+ return results.includes(true);
173
+ }
174
+ function hasDisplayNodeOrVisibilityHidden(el) {
175
+ const style = el.getAttribute('style');
176
+ if (!style) {
177
+ return false;
178
+ }
179
+ // TODO: Improve accuracy
180
+ return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
181
+ }
package/lib/index.d.ts CHANGED
@@ -1,16 +1,21 @@
1
1
  export * from './dom-traverse/accname-computation';
2
2
  export * from './dom-traverse/get-attr-specs';
3
+ export * from './dom-traverse/get-computed-aria-props';
3
4
  export * from './dom-traverse/get-computed-role';
4
5
  export * from './dom-traverse/get-content-model';
5
6
  export * from './dom-traverse/get-implicit-role';
6
7
  export * from './dom-traverse/get-permitted-roles';
7
8
  export * from './dom-traverse/get-spec';
8
9
  export * from './dom-traverse/has-required-owned-elements';
10
+ export * from './dom-traverse/is-exposed';
9
11
  export * from './dom-traverse/may-be-focusable';
10
12
  export * from './specs/aria-specs';
11
13
  export * from './specs/content-model-category-to-tag-names';
12
14
  export * from './specs/get-role-spec';
13
15
  export * from './specs/get-spec-by-tag-name';
16
+ export * from './specs/is-nothing-content-model';
17
+ export * from './specs/is-palpable-elements';
18
+ export * from './specs/is-void-element';
14
19
  export * from './specs/schema-to-spec';
15
20
  export * from './types';
16
21
  export * from './types/aria';
package/lib/index.js CHANGED
@@ -3,17 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./dom-traverse/accname-computation"), exports);
5
5
  tslib_1.__exportStar(require("./dom-traverse/get-attr-specs"), exports);
6
+ tslib_1.__exportStar(require("./dom-traverse/get-computed-aria-props"), exports);
6
7
  tslib_1.__exportStar(require("./dom-traverse/get-computed-role"), exports);
7
8
  tslib_1.__exportStar(require("./dom-traverse/get-content-model"), exports);
8
9
  tslib_1.__exportStar(require("./dom-traverse/get-implicit-role"), exports);
9
10
  tslib_1.__exportStar(require("./dom-traverse/get-permitted-roles"), exports);
10
11
  tslib_1.__exportStar(require("./dom-traverse/get-spec"), exports);
11
12
  tslib_1.__exportStar(require("./dom-traverse/has-required-owned-elements"), exports);
13
+ tslib_1.__exportStar(require("./dom-traverse/is-exposed"), exports);
12
14
  tslib_1.__exportStar(require("./dom-traverse/may-be-focusable"), exports);
13
15
  tslib_1.__exportStar(require("./specs/aria-specs"), exports);
14
16
  tslib_1.__exportStar(require("./specs/content-model-category-to-tag-names"), exports);
15
17
  tslib_1.__exportStar(require("./specs/get-role-spec"), exports);
16
18
  tslib_1.__exportStar(require("./specs/get-spec-by-tag-name"), exports);
19
+ tslib_1.__exportStar(require("./specs/is-nothing-content-model"), exports);
20
+ tslib_1.__exportStar(require("./specs/is-palpable-elements"), exports);
21
+ tslib_1.__exportStar(require("./specs/is-void-element"), exports);
17
22
  tslib_1.__exportStar(require("./specs/schema-to-spec"), exports);
18
23
  tslib_1.__exportStar(require("./types"), exports);
19
24
  tslib_1.__exportStar(require("./types/aria"), exports);
@@ -1,7 +1,7 @@
1
1
  import type { MLMLSpec, Attribute } from '../types';
2
2
  import type { NamespaceURI } from '@markuplint/ml-ast';
3
3
  export declare function getAttrSpecs(localName: string, namespace: NamespaceURI | null, schema: MLMLSpec): Attribute[] | null;
4
- declare type HasName = {
4
+ type HasName = {
5
5
  name: string;
6
6
  };
7
7
  export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
@@ -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,12 @@
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(el) {
10
+ return (0, is_void_element_1.isVoidElement)(el) || ['iframe', 'template'].includes(el.localName);
11
+ }
12
+ exports.isNothingContentModel = isNothingContentModel;
@@ -0,0 +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;
5
+ }): boolean;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPalpableElement = void 0;
4
+ /**
5
+ * Exposable content models and elements
6
+ *
7
+ * **WARNING**:
8
+ * This implementation is through the author's interpretation.
9
+ * Want a issue request.
10
+ * https://github.com/markuplint/markuplint/issues/new
11
+ *
12
+ * @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
13
+ */
14
+ const exposableElementsThatAreNoBelongingAModel = [
15
+ 'body',
16
+ 'dd',
17
+ 'dt',
18
+ 'figcaption',
19
+ 'html',
20
+ 'legend',
21
+ 'li',
22
+ 'optgroup',
23
+ 'option',
24
+ 'rp',
25
+ 'rt',
26
+ 'summary',
27
+ 'tbody',
28
+ 'td',
29
+ 'tfoot',
30
+ 'th',
31
+ 'thead',
32
+ 'tr',
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(',')) || ''];
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(',')) || '');
39
+ }
40
+ if (options === null || options === void 0 ? void 0 : options.extendsExposableElements /* default false */) {
41
+ conditions.push(exposableElementsThatAreNoBelongingAModel.join(','));
42
+ }
43
+ return conditions.some(condition => {
44
+ return el.matches(condition);
45
+ });
46
+ }
47
+ exports.isPalpableElement = isPalpableElement;
@@ -0,0 +1 @@
1
+ export declare function isVoidElement(el: Element): boolean;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVoidElement = void 0;
4
+ /**
5
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#void-elements
6
+ */
7
+ const voidElements = [
8
+ 'area',
9
+ 'base',
10
+ 'br',
11
+ 'col',
12
+ 'embed',
13
+ 'hr',
14
+ 'img',
15
+ 'input',
16
+ 'link',
17
+ 'meta',
18
+ 'source',
19
+ 'track',
20
+ 'wbr',
21
+ ];
22
+ function isVoidElement(el) {
23
+ return voidElements.includes(el.localName);
24
+ }
25
+ exports.isVoidElement = isVoidElement;
@@ -2,7 +2,7 @@ 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
  */
@@ -5,7 +5,7 @@ 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
  */
@@ -6,11 +6,11 @@
6
6
  /**
7
7
  * If `false`, this mean is "No corresponding role".
8
8
  */
9
- export declare type ImplicitRole = false | string;
9
+ 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 declare type PermittedRoles = boolean | (string | {
13
+ export type PermittedRoles = boolean | (string | {
14
14
  name: string;
15
15
  deprecated?: true;
16
16
  [k: string]: unknown;
@@ -22,7 +22,7 @@ export declare type PermittedRoles = boolean | (string | {
22
22
  * If set false:
23
23
  * > No role or aria-* attributes
24
24
  */
25
- export declare type PermittedARIAProperties = false | {
25
+ export type PermittedARIAProperties = false | {
26
26
  global?: true;
27
27
  /**
28
28
  * Set true if the spec says "and any aria-* attributes applicable to the allowed roles."