@markuplint/ml-spec 3.11.0 → 4.0.0-alpha.1
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/constant/aria-version.js +2 -5
- package/lib/dom-traverse/accname-computation.js +4 -7
- package/lib/dom-traverse/get-attr-specs.d.ts +2 -2
- package/lib/dom-traverse/get-attr-specs.js +3 -7
- package/lib/dom-traverse/get-computed-aria-props.d.ts +1 -1
- package/lib/dom-traverse/get-computed-aria-props.js +7 -12
- package/lib/dom-traverse/get-computed-role.d.ts +1 -1
- package/lib/dom-traverse/get-computed-role.js +28 -32
- package/lib/dom-traverse/get-content-model.d.ts +2 -2
- package/lib/dom-traverse/get-content-model.js +5 -10
- package/lib/dom-traverse/get-explicit-role.d.ts +1 -1
- package/lib/dom-traverse/get-explicit-role.js +9 -14
- package/lib/dom-traverse/get-implicit-role.d.ts +2 -2
- package/lib/dom-traverse/get-implicit-role.js +8 -13
- package/lib/dom-traverse/get-non-presentational-ancestor.d.ts +2 -2
- package/lib/dom-traverse/get-non-presentational-ancestor.js +5 -10
- package/lib/dom-traverse/get-permitted-roles.d.ts +1 -1
- package/lib/dom-traverse/get-permitted-roles.js +3 -7
- package/lib/dom-traverse/get-spec.d.ts +1 -1
- package/lib/dom-traverse/get-spec.js +3 -7
- package/lib/dom-traverse/has-required-owned-elements.d.ts +1 -1
- package/lib/dom-traverse/has-required-owned-elements.js +12 -19
- package/lib/dom-traverse/is-exposed.d.ts +1 -1
- package/lib/dom-traverse/is-exposed.js +15 -22
- package/lib/dom-traverse/matches-context-role.d.ts +1 -1
- package/lib/dom-traverse/matches-context-role.js +4 -8
- package/lib/dom-traverse/may-be-focusable.d.ts +1 -1
- package/lib/dom-traverse/may-be-focusable.js +3 -7
- package/lib/index.d.ts +28 -28
- package/lib/index.js +28 -33
- package/lib/specs/aria-specs.d.ts +4 -4
- package/lib/specs/aria-specs.js +1 -5
- package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
- package/lib/specs/content-model-category-to-tag-names.js +1 -5
- package/lib/specs/get-aria.d.ts +2 -2
- package/lib/specs/get-aria.js +10 -16
- package/lib/specs/get-attr-specs.d.ts +1 -1
- package/lib/specs/get-attr-specs.js +4 -9
- package/lib/specs/get-implicit-role.d.ts +2 -2
- package/lib/specs/get-implicit-role.js +3 -7
- package/lib/specs/get-permitted-roles.d.ts +1 -1
- package/lib/specs/get-permitted-roles.js +14 -17
- package/lib/specs/get-role-spec.d.ts +1 -1
- package/lib/specs/get-role-spec.js +10 -14
- package/lib/specs/get-selectors-by-content-model-category.d.ts +2 -2
- package/lib/specs/get-selectors-by-content-model-category.js +2 -6
- package/lib/specs/get-spec-by-tag-name.d.ts +1 -1
- package/lib/specs/get-spec-by-tag-name.js +4 -9
- package/lib/specs/is-nothing-content-model.js +3 -7
- package/lib/specs/is-palpable-elements.d.ts +1 -1
- package/lib/specs/is-palpable-elements.js +5 -10
- package/lib/specs/is-presentational.js +1 -5
- package/lib/specs/is-void-element.js +1 -5
- package/lib/specs/resolve-version.d.ts +2 -2
- package/lib/specs/resolve-version.js +7 -12
- package/lib/specs/schema-to-spec.d.ts +3 -3
- package/lib/specs/schema-to-spec.js +18 -23
- package/lib/types/aria.js +1 -2
- package/lib/types/attributes.js +1 -2
- package/lib/types/index.d.ts +4 -4
- package/lib/types/index.js +1 -2
- package/lib/types/permitted-structures.js +1 -2
- package/lib/utils/get-ns.js +1 -5
- package/lib/utils/merge-array.js +1 -5
- package/lib/utils/resolve-namespace.js +4 -9
- package/lib/utils/validateAriaVersion.d.ts +1 -1
- package/lib/utils/validateAriaVersion.js +3 -7
- package/package.json +13 -8
- package/test/dom-traverse/accname-computation.spec.js +0 -69
- package/test/dom-traverse/get-computed-aria-props.spec.js +0 -758
- package/test/dom-traverse/get-computed-role.spec.js +0 -315
- package/test/dom-traverse/get-implicit-role.spec.js +0 -40
- package/test/dom-traverse/has-required-owned-elements.spec.js +0 -34
- package/test/dom-traverse/is-exposed.spec.js +0 -70
- package/test/dom-traverse/matches-context-role.spec.js +0 -60
- package/test/specs/get-attr-specs.spec.js +0 -41
- package/test/specs/get-implicit-role.spec.js +0 -79
- package/test/specs/get-permitted-roles.spec.js +0 -418
- package/test/specs/get-role-spec.spec.js +0 -67
- package/test/specs/get-spec-by-tag-name.spec.js +0 -68
- package/test/specs/resolve-version.spec.js +0 -34
- package/test/specs/schema-to-spec.spec.js +0 -61
- package/test/utils/resolve-namespace.spec.js +0 -37
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ElementSpec } from '../types';
|
|
1
|
+
import type { ElementSpec } from '../types/index.js';
|
|
2
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,17 +1,12 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
8
|
-
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace !== null && namespace !== void 0 ? namespace : undefined);
|
|
3
|
+
export function getSpecByTagName(specs, localName, namespace) {
|
|
4
|
+
const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined);
|
|
9
5
|
let spec = cache.get(localNameWithNS);
|
|
10
6
|
if (spec !== undefined) {
|
|
11
7
|
return spec;
|
|
12
8
|
}
|
|
13
|
-
spec =
|
|
9
|
+
spec = specs.find(spec => spec.name === localNameWithNS) ?? null;
|
|
14
10
|
cache.set(localNameWithNS, spec);
|
|
15
11
|
return spec;
|
|
16
12
|
}
|
|
17
|
-
exports.getSpecByTagName = getSpecByTagName;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
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(
|
|
6
|
+
export function isNothingContentModel(
|
|
10
7
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
11
8
|
el) {
|
|
12
|
-
return
|
|
9
|
+
return isVoidElement(el) || ['iframe', 'template'].includes(el.localName);
|
|
13
10
|
}
|
|
14
|
-
exports.isNothingContentModel = isNothingContentModel;
|
|
@@ -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,19 +28,17 @@ const exposableElementsThatAreNoBelongingAModel = [
|
|
|
31
28
|
'thead',
|
|
32
29
|
'tr',
|
|
33
30
|
];
|
|
34
|
-
function isPalpableElement(
|
|
31
|
+
export function isPalpableElement(
|
|
35
32
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
36
33
|
el, specs, options) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
conditions.push((_d = (_c = specs.def['#contentModels']['#SVGRenderable']) === null || _c === void 0 ? void 0 : _c.join(',')) !== null && _d !== void 0 ? _d : '');
|
|
34
|
+
const conditions = [specs.def['#contentModels']['#palpable']?.join(',') ?? ''];
|
|
35
|
+
if (options?.extendsSvg !== false /* default true */) {
|
|
36
|
+
conditions.push(specs.def['#contentModels']['#SVGRenderable']?.join(',') ?? '');
|
|
41
37
|
}
|
|
42
|
-
if (options
|
|
38
|
+
if (options?.extendsExposableElements /* default false */) {
|
|
43
39
|
conditions.push(exposableElementsThatAreNoBelongingAModel.join(','));
|
|
44
40
|
}
|
|
45
41
|
return conditions.some(condition => {
|
|
46
42
|
return el.matches(condition);
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
|
-
exports.isPalpableElement = isPalpableElement;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
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,9 +16,8 @@ const voidElements = [
|
|
|
19
16
|
'track',
|
|
20
17
|
'wbr',
|
|
21
18
|
];
|
|
22
|
-
function isVoidElement(
|
|
19
|
+
export function isVoidElement(
|
|
23
20
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
24
21
|
el) {
|
|
25
22
|
return voidElements.includes(el.localName);
|
|
26
23
|
}
|
|
27
|
-
exports.isVoidElement = isVoidElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ARIA } from '../types/aria.js';
|
|
2
|
+
import type { ARIAVersion } from '../types/index.js';
|
|
3
3
|
import type { ReadonlyDeep } from 'type-fest';
|
|
4
4
|
export declare function resolveVersion(aria: ReadonlyDeep<ARIA>, version: ARIAVersion): Omit<ReadonlyDeep<ARIA>, ARIAVersion>;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
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.1' ? aria.namingProhibited : (_k = (_j = aria[version]) === null || _j === void 0 ? void 0 : _j.namingProhibited) !== null && _k !== void 0 ? _k : 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;
|
|
10
|
+
cites: import("../types/index.js").Cites;
|
|
11
|
+
def: import("../types/index.js").SpecDefs;
|
|
12
12
|
specs: readonly ElementSpec[];
|
|
13
13
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
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, _d, _e;
|
|
9
|
+
export function schemaToSpec(schemas) {
|
|
14
10
|
const [main, ...extendedSpecs] = schemas;
|
|
15
11
|
const result = { ...main };
|
|
16
12
|
for (const extendedSpec of extendedSpecs) {
|
|
@@ -19,30 +15,30 @@ function schemaToSpec(schemas) {
|
|
|
19
15
|
}
|
|
20
16
|
if (extendedSpec.def) {
|
|
21
17
|
const def = { ...result.def };
|
|
22
|
-
if (
|
|
18
|
+
if (extendedSpec.def['#globalAttrs']?.['#extends']) {
|
|
23
19
|
const gAttrs = { ...def['#globalAttrs'] };
|
|
24
20
|
gAttrs['#HTMLGlobalAttrs'] = {
|
|
25
|
-
...(
|
|
26
|
-
...(
|
|
21
|
+
...(def['#globalAttrs']?.['#HTMLGlobalAttrs'] ?? {}),
|
|
22
|
+
...(extendedSpec.def['#globalAttrs']?.['#extends'] ?? {}),
|
|
27
23
|
};
|
|
28
24
|
def['#globalAttrs'] = gAttrs;
|
|
29
25
|
}
|
|
30
26
|
if (extendedSpec.def['#aria']) {
|
|
31
27
|
def['#aria'] = {
|
|
32
28
|
'1.1': {
|
|
33
|
-
roles:
|
|
34
|
-
props:
|
|
35
|
-
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),
|
|
36
32
|
},
|
|
37
33
|
'1.2': {
|
|
38
|
-
roles:
|
|
39
|
-
props:
|
|
40
|
-
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),
|
|
41
37
|
},
|
|
42
38
|
'1.3': {
|
|
43
|
-
roles:
|
|
44
|
-
props:
|
|
45
|
-
graphicsRoles:
|
|
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),
|
|
46
42
|
},
|
|
47
43
|
};
|
|
48
44
|
}
|
|
@@ -55,7 +51,7 @@ function schemaToSpec(schemas) {
|
|
|
55
51
|
for (const modelName of keys) {
|
|
56
52
|
const mainModel = def['#contentModels'][modelName];
|
|
57
53
|
const exModel = extendedSpec.def['#contentModels'][modelName];
|
|
58
|
-
models[modelName] = [...(mainModel
|
|
54
|
+
models[modelName] = [...(mainModel ?? []), ...(exModel ?? [])];
|
|
59
55
|
}
|
|
60
56
|
def['#contentModels'] = models;
|
|
61
57
|
}
|
|
@@ -77,10 +73,10 @@ function schemaToSpec(schemas) {
|
|
|
77
73
|
...exSpec,
|
|
78
74
|
globalAttrs: {
|
|
79
75
|
...elSpec.globalAttrs,
|
|
80
|
-
...exSpec
|
|
76
|
+
...exSpec?.globalAttrs,
|
|
81
77
|
},
|
|
82
|
-
attributes: mergeAttrSpec(elSpec.attributes, exSpec
|
|
83
|
-
categories:
|
|
78
|
+
attributes: mergeAttrSpec(elSpec.attributes, exSpec?.attributes),
|
|
79
|
+
categories: mergeArray(elSpec.categories, exSpec?.categories),
|
|
84
80
|
});
|
|
85
81
|
}
|
|
86
82
|
result.specs = specs;
|
|
@@ -88,7 +84,6 @@ function schemaToSpec(schemas) {
|
|
|
88
84
|
}
|
|
89
85
|
return result;
|
|
90
86
|
}
|
|
91
|
-
exports.schemaToSpec = schemaToSpec;
|
|
92
87
|
function mergeAttrSpec(std, ex = {}) {
|
|
93
88
|
const result = {};
|
|
94
89
|
const keys = Array.from(new Set([...Object.keys(std), ...Object.keys(ex)]));
|
package/lib/types/aria.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* This file was automatically generated by json-schema-to-typescript.
|
|
4
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
4
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
5
|
*/
|
|
7
|
-
|
|
6
|
+
export {};
|
package/lib/types/attributes.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* This file was automatically generated by json-schema-to-typescript.
|
|
4
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
4
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
5
|
*/
|
|
7
|
-
|
|
6
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ARIA } from './aria';
|
|
2
|
-
import type { AttributeJSON, AttributeType, GlobalAttributes } from './attributes';
|
|
3
|
-
import type { ContentModel, Category } from './permitted-structures';
|
|
4
|
-
import type { ariaVersions } from '../constant/aria-version';
|
|
1
|
+
import type { ARIA } from './aria.js';
|
|
2
|
+
import type { AttributeJSON, AttributeType, GlobalAttributes } from './attributes.js';
|
|
3
|
+
import type { ContentModel, Category } from './permitted-structures.js';
|
|
4
|
+
import type { ariaVersions } from '../constant/aria-version.js';
|
|
5
5
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
6
6
|
import type { ReadonlyDeep } from 'type-fest';
|
|
7
7
|
/**
|
package/lib/types/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* This file was automatically generated by json-schema-to-typescript.
|
|
4
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
4
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
5
|
*/
|
|
7
|
-
|
|
6
|
+
export {};
|
package/lib/utils/get-ns.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNS = void 0;
|
|
4
|
-
function getNS(namespaceURI) {
|
|
1
|
+
export function getNS(namespaceURI) {
|
|
5
2
|
switch (namespaceURI) {
|
|
6
3
|
case 'http://www.w3.org/2000/svg': {
|
|
7
4
|
return 'svg';
|
|
@@ -17,4 +14,3 @@ function getNS(namespaceURI) {
|
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.getNS = getNS;
|
package/lib/utils/merge-array.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeArray = void 0;
|
|
4
|
-
function mergeArray(a, b) {
|
|
1
|
+
export function mergeArray(a, b) {
|
|
5
2
|
if (!b) {
|
|
6
3
|
return a;
|
|
7
4
|
}
|
|
@@ -29,7 +26,6 @@ function mergeArray(a, b) {
|
|
|
29
26
|
}
|
|
30
27
|
return result;
|
|
31
28
|
}
|
|
32
|
-
exports.mergeArray = mergeArray;
|
|
33
29
|
function getName(def) {
|
|
34
30
|
const result = typeof def === 'string' ? def : def.name;
|
|
35
31
|
return result.toLowerCase().trim();
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveNamespace = void 0;
|
|
4
|
-
const get_ns_1 = require("./get-ns");
|
|
1
|
+
import { getNS } from './get-ns.js';
|
|
5
2
|
const cache = new Map();
|
|
6
3
|
const namespaceURIMap = {
|
|
7
4
|
html: 'http://www.w3.org/1999/xhtml',
|
|
@@ -9,16 +6,15 @@ const namespaceURIMap = {
|
|
|
9
6
|
mml: 'http://www.w3.org/1998/Math/MathML',
|
|
10
7
|
xlink: 'http://www.w3.org/1999/xlink',
|
|
11
8
|
};
|
|
12
|
-
function resolveNamespace(name, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
13
|
-
var _a;
|
|
9
|
+
export function resolveNamespace(name, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
14
10
|
const cached = cache.get(name + namespaceURI);
|
|
15
11
|
if (cached) {
|
|
16
12
|
return cached;
|
|
17
13
|
}
|
|
18
14
|
const [_explicitNS, _localName] = name.split(':');
|
|
19
15
|
const explicitNS = _localName ? _explicitNS : null;
|
|
20
|
-
const localName =
|
|
21
|
-
const namespace = ['html', 'svg', 'mml', 'xlink'].find(_ns => _ns === (explicitNS ||
|
|
16
|
+
const localName = _localName ?? _explicitNS ?? '';
|
|
17
|
+
const namespace = ['html', 'svg', 'mml', 'xlink'].find(_ns => _ns === (explicitNS || getNS(namespaceURI ?? null))) ||
|
|
22
18
|
'html';
|
|
23
19
|
const result = {
|
|
24
20
|
localNameWithNS: `${namespace === 'html' ? '' : `${namespace}:`}${localName}`,
|
|
@@ -29,4 +25,3 @@ function resolveNamespace(name, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
|
29
25
|
cache.set(name + namespaceURI, result);
|
|
30
26
|
return result;
|
|
31
27
|
}
|
|
32
|
-
exports.resolveNamespace = resolveNamespace;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ARIAVersion } from '../types';
|
|
1
|
+
import type { ARIAVersion } from '../types/index.js';
|
|
2
2
|
export declare function validateAriaVersion(version: string): version is ARIAVersion;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const aria_version_1 = require("../constant/aria-version");
|
|
5
|
-
function validateAriaVersion(version) {
|
|
6
|
-
return aria_version_1.ariaVersions.includes(version);
|
|
1
|
+
import { ariaVersions } from '../constant/aria-version.js';
|
|
2
|
+
export function validateAriaVersion(version) {
|
|
3
|
+
return ariaVersions.includes(version);
|
|
7
4
|
}
|
|
8
|
-
exports.validateAriaVersion = validateAriaVersion;
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-spec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "Types and schema that specs of the Markup languages for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"private": false,
|
|
9
|
-
"
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./lib/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
10
15
|
"types": "lib/index.d.ts",
|
|
11
16
|
"publishConfig": {
|
|
12
17
|
"access": "public"
|
|
@@ -25,16 +30,16 @@
|
|
|
25
30
|
"schema": "run-s schema:*"
|
|
26
31
|
},
|
|
27
32
|
"dependencies": {
|
|
28
|
-
"@markuplint/ml-ast": "
|
|
29
|
-
"@markuplint/types": "
|
|
33
|
+
"@markuplint/ml-ast": "4.0.0-alpha.1",
|
|
34
|
+
"@markuplint/types": "4.0.0-alpha.1",
|
|
30
35
|
"dom-accessibility-api": "^0.6.1",
|
|
31
36
|
"is-plain-object": "^5.0.0",
|
|
32
|
-
"tslib": "^2.6.
|
|
33
|
-
"type-fest": "^
|
|
37
|
+
"tslib": "^2.6.1",
|
|
38
|
+
"type-fest": "^4.1.0"
|
|
34
39
|
},
|
|
35
40
|
"devDependencies": {
|
|
36
|
-
"@markuplint/test-tools": "
|
|
41
|
+
"@markuplint/test-tools": "4.0.0-alpha.1",
|
|
37
42
|
"json-schema-to-typescript": "13.0.2"
|
|
38
43
|
},
|
|
39
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "22502ee22a378ae766033d687dbc0443e5ed35dc"
|
|
40
45
|
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const { createJSDOMElement: c } = require('@markuplint/test-tools');
|
|
2
|
-
|
|
3
|
-
const { getAccname } = require('../../lib/dom-traverse/accname-computation');
|
|
4
|
-
|
|
5
|
-
test('Get accessible name', () => {
|
|
6
|
-
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
7
|
-
expect(getAccname(c('<div>text</div>'))).toBe('');
|
|
8
|
-
expect(getAccname(c('<div aria-label="label">text</div>'))).toBe('label');
|
|
9
|
-
expect(getAccname(c('<span aria-label="label">text</span>'))).toBe('label');
|
|
10
|
-
expect(getAccname(c('<img alt="alternative-text" />'))).toBe('alternative-text');
|
|
11
|
-
expect(getAccname(c('<img title="title" />'))).toBe('title');
|
|
12
|
-
expect(getAccname(c('<div><label for="a">label</label><input id="a" /></div>').children[1])).toBe('label');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('Invisible element', () => {
|
|
16
|
-
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
17
|
-
expect(getAccname(c('<button aria-disabled="true">label</button>'))).toBe('label');
|
|
18
|
-
expect(getAccname(c('<button aria-hidden="true">label</button>'))).toBe('');
|
|
19
|
-
expect(getAccname(c('<button hidden>label</button>'))).toBe('');
|
|
20
|
-
expect(getAccname(c('<button style="display: none">label</button>'))).toBe('');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @see https://www.w3.org/TR/accname-1.1/#ex-1-example-1-element1-id-el1-aria-labelledby-el3-element2-id-el2-aria-labelledby-el1-element3-id-el3-hello-element3
|
|
25
|
-
*/
|
|
26
|
-
test('accname-1.1 Example 1', () => {
|
|
27
|
-
const complex = c(`<div>
|
|
28
|
-
<input id="el1" aria-labelledby="el3" />
|
|
29
|
-
<input id="el2" aria-labelledby="el1" />
|
|
30
|
-
<h1 id="el3"> hello </h1>
|
|
31
|
-
</div>`);
|
|
32
|
-
expect(getAccname(complex.children[0])).toBe('hello');
|
|
33
|
-
expect(getAccname(complex.children[1])).toBe('');
|
|
34
|
-
expect(getAccname(complex.children[2])).toBe('hello');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @see https://www.w3.org/TR/accname-1.1/#ex-2-example-2-h1-files-h1-ul-li-a-id-file_row1-href-files-documentation-pdf-documentation-pdf-a-span-role-button-tabindex-0-id-del_row1-aria-label-delete-aria-labelledby-del_row1-file_row1-span-li-li-a-id-file_row2-href-files-holidayletter-pdf-holidayletter-pdf-a-span-role-button-tabindex-0-id-del_row2-aria-label-delete-aria-labelledby-del_row2-file_row2-span-li-ul
|
|
39
|
-
*/
|
|
40
|
-
test('accname-1.1 Example 2', () => {
|
|
41
|
-
const complex = c(`<ul>
|
|
42
|
-
<li>
|
|
43
|
-
<a id="file_row1" href="./files/Documentation.pdf">Documentation.pdf</a>
|
|
44
|
-
<span role="button" tabindex="0" id="del_row1" aria-label="Delete" aria-labelledby="del_row1 file_row1"></span>
|
|
45
|
-
</li>
|
|
46
|
-
<li>
|
|
47
|
-
<a id="file_row2" href="./files/HolidayLetter.pdf">HolidayLetter.pdf</a>
|
|
48
|
-
<span role="button" tabindex="0" id="del_row2" aria-label="Delete" aria-labelledby="del_row2 file_row2"></span>
|
|
49
|
-
</li>
|
|
50
|
-
</ul>`);
|
|
51
|
-
const spans = complex.querySelectorAll('span');
|
|
52
|
-
expect(getAccname(spans[0])).toBe('Delete Documentation.pdf');
|
|
53
|
-
expect(getAccname(spans[1])).toBe('Delete HolidayLetter.pdf');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @see https://www.w3.org/TR/accname-1.1/#ex-3-example-3-div-role-checkbox-aria-checked-false-flash-the-screen-span-role-textbox-aria-multiline-false-5-span-times-div
|
|
58
|
-
*/
|
|
59
|
-
test('accname-1.1 Example 3', () => {
|
|
60
|
-
const complex = c(
|
|
61
|
-
'<div role="checkbox" aria-checked="false">Flash the screen <span role="textbox" aria-multiline="false"> 5 </span> times</div>',
|
|
62
|
-
);
|
|
63
|
-
expect(getAccname(complex)).toBe('Flash the screen 5 times');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('with comment', () => {
|
|
67
|
-
expect(getAccname(c('<button>label</button>'))).toBe('label');
|
|
68
|
-
expect(getAccname(c('<button>label<!-- comment --></button>'))).toBe('label');
|
|
69
|
-
});
|