@markuplint/ml-spec 3.0.0-alpha.5 → 3.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dom-traverse/get-attr-specs.d.ts +1 -1
- package/lib/dom-traverse/get-computed-aria-props.d.ts +8 -8
- package/lib/dom-traverse/get-content-model.d.ts +4 -1
- package/lib/dom-traverse/get-implicit-role.d.ts +5 -1
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +10 -4
- package/lib/dom-traverse/get-permitted-roles.d.ts +7 -3
- package/lib/dom-traverse/get-spec.d.ts +4 -1
- package/lib/dom-traverse/has-required-owned-elements.d.ts +6 -1
- package/lib/dom-traverse/is-exposed.js +2 -42
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/specs/aria-specs.d.ts +7 -4
- package/lib/specs/content-model-category-to-tag-names.d.ts +4 -1
- package/lib/specs/get-aria.d.ts +7 -1
- package/lib/specs/get-attr-specs.d.ts +7 -3
- package/lib/specs/get-implicit-role.d.ts +7 -1
- package/lib/specs/get-permitted-roles.d.ts +9 -3
- package/lib/specs/get-role-spec.d.ts +10 -3
- package/lib/specs/get-selectors-by-content-model-category.d.ts +4 -1
- package/lib/specs/get-spec-by-tag-name.d.ts +5 -1
- package/lib/specs/is-palpable-elements.d.ts +9 -0
- package/lib/specs/is-palpable-elements.js +47 -0
- package/lib/specs/is-void-element.d.ts +1 -0
- package/lib/specs/is-void-element.js +25 -0
- package/lib/specs/schema-to-spec.d.ts +3 -3
- package/lib/types/aria.d.ts +129 -115
- package/lib/types/attributes.d.ts +1437 -112
- package/lib/types/index.d.ts +192 -164
- package/lib/types/permitted-structres.d.ts +76 -37
- package/lib/types/permitted-structures.d.ts +72 -33
- package/lib/utils/merge-array.d.ts +5 -3
- package/lib/utils/resolve-namespace.d.ts +5 -5
- package/package.json +5 -5
- package/src/dom-traverse/is-exposed.ts +2 -43
- package/src/index.ts +2 -0
- package/src/specs/is-palpable-elements.ts +55 -0
- package/src/specs/is-void-element.ts +22 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
|
-
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): import(
|
|
2
|
+
export declare function getAttrSpecs(el: Element, schema: MLMLSpec): import('../types').Attribute[] | null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
9
|
};
|
|
10
|
-
|
|
10
|
+
type ARIAPropReferenceType = 'default' | 'html-attr' | 'aria-attr';
|
|
11
11
|
export declare function getComputedAriaProps(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ARIAProps;
|
|
12
12
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
2
|
import type { PermittedContentPattern } from '../types/permitted-structures';
|
|
3
|
-
export declare function getContentModel(
|
|
3
|
+
export declare function getContentModel(
|
|
4
|
+
el: Element,
|
|
5
|
+
specs: Pick<ElementSpec, 'name' | 'contentModel'>[],
|
|
6
|
+
): boolean | PermittedContentPattern[] | null;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
2
|
export declare function getImplicitRole(specs: Readonly<MLMLSpec>, el: Element, version: ARIAVersion): ComputedRole;
|
|
3
|
-
export declare function getImplicitRoleName(
|
|
3
|
+
export declare function getImplicitRoleName(
|
|
4
|
+
el: Element,
|
|
5
|
+
version: ARIAVersion,
|
|
6
|
+
specs: Readonly<MLMLSpec>,
|
|
7
|
+
): import('..').ImplicitRole;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getNonPresentationalAncestor(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function getNonPresentationalAncestor(
|
|
3
|
+
el: Element,
|
|
4
|
+
specs: MLMLSpec,
|
|
5
|
+
version: ARIAVersion,
|
|
6
|
+
):
|
|
7
|
+
| import('../types').ComputedRole
|
|
8
|
+
| {
|
|
9
|
+
el: null;
|
|
10
|
+
role: null;
|
|
11
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getPermittedRoles(
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export declare function getPermittedRoles(
|
|
3
|
+
el: Element,
|
|
4
|
+
version: ARIAVersion,
|
|
5
|
+
specs: Readonly<MLMLSpec>,
|
|
6
|
+
): {
|
|
7
|
+
name: string;
|
|
8
|
+
deprecated?: boolean | undefined;
|
|
5
9
|
}[];
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpec<K extends keyof ElementSpec>(
|
|
2
|
+
export declare function getSpec<K extends keyof ElementSpec>(
|
|
3
|
+
el: Element,
|
|
4
|
+
specs: Pick<ElementSpec, 'name' | K>[],
|
|
5
|
+
): Pick<ElementSpec, 'name' | K> | null;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../types';
|
|
2
2
|
export declare function hasRequiredOwnedElement(el: Element, specs: Readonly<MLMLSpec>, version: ARIAVersion): boolean;
|
|
3
|
-
export declare function isRequiredOwnedElement(
|
|
3
|
+
export declare function isRequiredOwnedElement(
|
|
4
|
+
owned: ComputedRole,
|
|
5
|
+
query: string,
|
|
6
|
+
specs: MLMLSpec,
|
|
7
|
+
version: ARIAVersion,
|
|
8
|
+
): boolean;
|
|
@@ -2,40 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isExposed = void 0;
|
|
4
4
|
const aria_specs_1 = require("../specs/aria-specs");
|
|
5
|
+
const is_palpable_elements_1 = require("../specs/is-palpable-elements");
|
|
5
6
|
const is_presentational_1 = require("../specs/is-presentational");
|
|
6
7
|
const get_computed_role_1 = require("./get-computed-role");
|
|
7
|
-
/**
|
|
8
|
-
* Exposable content models and elements
|
|
9
|
-
*
|
|
10
|
-
* **WARNING**:
|
|
11
|
-
* This implementation is through the author's interpretation.
|
|
12
|
-
* Want a issue request.
|
|
13
|
-
* https://github.com/markuplint/markuplint/issues/new
|
|
14
|
-
*
|
|
15
|
-
* @see exposableModels https://html.spec.whatwg.org/multipage/dom.html#content-models
|
|
16
|
-
* @see exposableElementsThatAreNoBelongingAModel https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
|
17
|
-
*/
|
|
18
|
-
const exposableModels = ['#palpable', '#SVGRenderable'];
|
|
19
|
-
const exposableElementsThatAreNoBelongingAModel = [
|
|
20
|
-
'body',
|
|
21
|
-
'dd',
|
|
22
|
-
'dt',
|
|
23
|
-
'figcaption',
|
|
24
|
-
'html',
|
|
25
|
-
'legend',
|
|
26
|
-
'li',
|
|
27
|
-
'optgroup',
|
|
28
|
-
'option',
|
|
29
|
-
'rp',
|
|
30
|
-
'rt',
|
|
31
|
-
'summary',
|
|
32
|
-
'tbody',
|
|
33
|
-
'td',
|
|
34
|
-
'tfoot',
|
|
35
|
-
'th',
|
|
36
|
-
'thead',
|
|
37
|
-
'tr',
|
|
38
|
-
];
|
|
39
8
|
/**
|
|
40
9
|
* Detect including/excluding from the Accessibility Tree
|
|
41
10
|
*
|
|
@@ -52,16 +21,7 @@ function isExposed(el, specs, version) {
|
|
|
52
21
|
}
|
|
53
22
|
// According to HTML and SVG Specs with **the author's interpretation**
|
|
54
23
|
{
|
|
55
|
-
|
|
56
|
-
.map(model => {
|
|
57
|
-
var _a;
|
|
58
|
-
return ((_a = specs.def['#contentModels'][model]) === null || _a === void 0 ? void 0 : _a.join(',')) || '';
|
|
59
|
-
})
|
|
60
|
-
.concat(exposableElementsThatAreNoBelongingAModel.join(','));
|
|
61
|
-
const exposable = exposableConditions.some(condition => {
|
|
62
|
-
return el.matches(condition);
|
|
63
|
-
});
|
|
64
|
-
if (!exposable) {
|
|
24
|
+
if (!(0, is_palpable_elements_1.isPalpableElement)(el, specs, { extendsSvg: true, extendsExposableElements: true })) {
|
|
65
25
|
return false;
|
|
66
26
|
}
|
|
67
27
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export * from './specs/aria-specs';
|
|
|
13
13
|
export * from './specs/content-model-category-to-tag-names';
|
|
14
14
|
export * from './specs/get-role-spec';
|
|
15
15
|
export * from './specs/get-spec-by-tag-name';
|
|
16
|
+
export * from './specs/is-palpable-elements';
|
|
17
|
+
export * from './specs/is-void-element';
|
|
16
18
|
export * from './specs/schema-to-spec';
|
|
17
19
|
export * from './types';
|
|
18
20
|
export * from './types/aria';
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,8 @@ tslib_1.__exportStar(require("./specs/aria-specs"), exports);
|
|
|
16
16
|
tslib_1.__exportStar(require("./specs/content-model-category-to-tag-names"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./specs/get-role-spec"), exports);
|
|
18
18
|
tslib_1.__exportStar(require("./specs/get-spec-by-tag-name"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./specs/is-palpable-elements"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./specs/is-void-element"), exports);
|
|
19
21
|
tslib_1.__exportStar(require("./specs/schema-to-spec"), exports);
|
|
20
22
|
tslib_1.__exportStar(require("./types"), exports);
|
|
21
23
|
tslib_1.__exportStar(require("./types/aria"), exports);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../types';
|
|
2
|
-
export declare function ariaSpecs(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function ariaSpecs(
|
|
3
|
+
specs: Readonly<MLMLSpec>,
|
|
4
|
+
version: ARIAVersion,
|
|
5
|
+
): {
|
|
6
|
+
roles: import('../types').ARIARoleInSchema[];
|
|
7
|
+
graphicsRoles: import('../types').ARIARoleInSchema[];
|
|
8
|
+
props: import('../types').ARIAProperty[];
|
|
6
9
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
2
|
import type { Category } from '../types/permitted-structures';
|
|
3
|
-
export declare function contentModelCategoryToTagNames(
|
|
3
|
+
export declare function contentModelCategoryToTagNames(
|
|
4
|
+
contentModel: Category,
|
|
5
|
+
def: MLMLSpec['def'],
|
|
6
|
+
): ReadonlyArray<string>;
|
package/lib/specs/get-aria.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
2
|
import type { ARIA } from '../types/aria';
|
|
3
|
-
export declare function getARIA(
|
|
3
|
+
export declare function getARIA(
|
|
4
|
+
specs: Readonly<MLMLSpec>,
|
|
5
|
+
localName: string,
|
|
6
|
+
namespace: string | null,
|
|
7
|
+
version: ARIAVersion,
|
|
8
|
+
matches: Matches,
|
|
9
|
+
): Omit<ARIA, ARIAVersion | 'conditions'> | null;
|
|
@@ -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(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function getAttrSpecs(
|
|
4
|
+
localName: string,
|
|
5
|
+
namespace: NamespaceURI | null,
|
|
6
|
+
schema: MLMLSpec,
|
|
7
|
+
): Attribute[] | null;
|
|
8
|
+
type HasName = {
|
|
9
|
+
name: string;
|
|
6
10
|
};
|
|
7
11
|
export declare function nameCompare(a: HasName | string, b: HasName | string): 1 | -1 | 0;
|
|
8
12
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { ARIAVersion, Matches, MLMLSpec } from '../types';
|
|
2
|
-
export declare function getImplicitRole(
|
|
2
|
+
export declare function getImplicitRole(
|
|
3
|
+
specs: Readonly<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(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export declare function getPermittedRoles(
|
|
10
|
+
specs: Readonly<MLMLSpec>,
|
|
11
|
+
localName: string,
|
|
12
|
+
namespace: string | null,
|
|
13
|
+
version: ARIAVersion,
|
|
14
|
+
matches: Matches,
|
|
15
|
+
): {
|
|
16
|
+
name: string;
|
|
17
|
+
deprecated?: boolean;
|
|
12
18
|
}[];
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../types';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
-
export declare function getRoleSpec(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function getRoleSpec(
|
|
4
|
+
specs: Readonly<MLMLSpec>,
|
|
5
|
+
roleName: string,
|
|
6
|
+
namespace: NamespaceURI,
|
|
7
|
+
version: ARIAVersion,
|
|
8
|
+
):
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
superClassRoles: ARIARoleInSchema[];
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../types';
|
|
2
2
|
import type { Category } from '../types/permitted-structures';
|
|
3
|
-
export declare function getSelectorsByContentModelCategory(
|
|
3
|
+
export declare function getSelectorsByContentModelCategory(
|
|
4
|
+
specs: Readonly<MLMLSpec>,
|
|
5
|
+
category: Category,
|
|
6
|
+
): ReadonlyArray<string>;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { ElementSpec } from '../types';
|
|
2
|
-
export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(
|
|
2
|
+
export declare function getSpecByTagName<K extends keyof ElementSpec = keyof ElementSpec>(
|
|
3
|
+
specs: Readonly<Pick<ElementSpec, 'name' | K>[]>,
|
|
4
|
+
localName: string,
|
|
5
|
+
namespace: string | null,
|
|
6
|
+
): Pick<ElementSpec, 'name' | K> | null;
|
|
@@ -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;
|
|
@@ -7,7 +7,7 @@ import type { ElementSpec, ExtendedSpec, MLMLSpec } from '../types';
|
|
|
7
7
|
* @param schemas `MLDocument.schemas`
|
|
8
8
|
*/
|
|
9
9
|
export declare function schemaToSpec(schemas: readonly [MLMLSpec, ...ExtendedSpec[]]): {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
cites: import('../types').Cites;
|
|
11
|
+
def: import('../types').SpecDefs;
|
|
12
|
+
specs: ElementSpec[];
|
|
13
13
|
};
|