@markuplint/ml-spec 3.0.0-alpha.82 → 3.0.0-rc.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.
- package/README.md +7 -2
- package/lib/dom-traverse/get-computed-aria-props.d.ts +12 -0
- package/lib/dom-traverse/get-computed-aria-props.js +106 -0
- package/lib/dom-traverse/get-computed-role.js +13 -25
- package/lib/dom-traverse/get-content-model.d.ts +3 -0
- package/lib/dom-traverse/get-content-model.js +28 -0
- package/lib/dom-traverse/get-spec.d.ts +2 -2
- package/lib/dom-traverse/get-spec.js +2 -2
- package/lib/dom-traverse/has-required-owned-elements.js +12 -0
- package/lib/dom-traverse/is-exposed.d.ts +11 -0
- package/lib/dom-traverse/is-exposed.js +181 -0
- package/lib/dom-traverse/may-be-focusable.d.ts +2 -0
- package/lib/dom-traverse/may-be-focusable.js +22 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +7 -1
- package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
- package/lib/specs/content-model-category-to-tag-names.js +2 -2
- package/lib/specs/get-aria.js +3 -3
- package/lib/specs/get-attr-specs.d.ts +1 -1
- package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -1
- package/lib/specs/get-spec-by-tag-name.d.ts +2 -2
- package/lib/specs/get-spec-by-tag-name.js +1 -1
- package/lib/specs/is-palpable-elements.d.ts +5 -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 +1 -1
- package/lib/specs/schema-to-spec.js +1 -1
- package/lib/types/aria.d.ts +10 -4
- package/lib/types/attributes.d.ts +94 -39
- package/lib/types/index.d.ts +27 -27
- package/lib/types/permitted-structres.d.ts +22 -28
- package/lib/types/permitted-structures.d.ts +54 -0
- package/lib/types/permitted-structures.js +8 -0
- package/lib/utils/get-ns.d.ts +2 -1
- package/lib/utils/get-ns.js +3 -0
- package/lib/utils/merge-array.d.ts +1 -1
- package/lib/utils/resolve-namespace.d.ts +4 -4
- package/lib/utils/resolve-namespace.js +18 -13
- package/package.json +7 -7
- package/schema.json +6 -6
- package/schemas/aria.schema.json +1 -1
- package/schemas/content-models.schema.json +33 -49
- package/src/dom-traverse/accname-computation.spec.ts +4 -4
- package/src/dom-traverse/get-computed-aria-props.spec.ts +368 -0
- package/src/dom-traverse/get-computed-aria-props.ts +130 -0
- package/src/dom-traverse/get-computed-role.spec.ts +1 -1
- package/src/dom-traverse/get-computed-role.ts +13 -25
- package/src/dom-traverse/get-content-model.ts +32 -0
- package/src/dom-traverse/get-spec.ts +3 -3
- package/src/dom-traverse/has-required-owned-elements.ts +13 -0
- package/src/dom-traverse/is-exposed.spec.ts +50 -0
- package/src/dom-traverse/is-exposed.ts +196 -0
- package/src/dom-traverse/may-be-focusable.ts +21 -0
- package/src/index.ts +7 -1
- package/src/specs/content-model-category-to-tag-names.ts +3 -3
- package/src/specs/get-aria.ts +3 -3
- package/src/specs/get-selectors-by-content-model-category.ts +1 -1
- package/src/specs/get-spec-by-tag-name.spec.ts +10 -10
- package/src/specs/get-spec-by-tag-name.ts +9 -5
- package/src/specs/is-palpable-elements.ts +55 -0
- package/src/specs/is-void-element.ts +22 -0
- package/src/specs/schema-to-spec.ts +1 -1
- package/src/types/aria.ts +7 -1
- package/src/types/attributes.ts +160 -105
- package/src/types/index.ts +8 -8
- package/src/types/permitted-structres.ts +24 -32
- package/src/types/permitted-structures.ts +96 -0
- package/src/utils/get-ns.ts +6 -1
- package/src/utils/resolve-namespace.spec.ts +37 -0
- package/src/utils/resolve-namespace.ts +22 -18
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/dom-traverse/focusability-computation.d.ts +0 -1
- package/lib/dom-traverse/focusability-computation.js +0 -8
- package/lib/dom-traverse/get-aria.d.ts +0 -9
- package/lib/dom-traverse/get-aria.js +0 -54
- package/lib/specs/aria-spec.d.ts +0 -5
- package/lib/specs/aria-spec.js +0 -12
- package/lib/specs/get-spec.d.ts +0 -13
- package/lib/specs/get-spec.js +0 -85
- package/lib/specs/html-spec.d.ts +0 -6
- package/lib/specs/html-spec.js +0 -16
- package/lib/specs/resolve-namespace.d.ts +0 -9
- package/lib/specs/resolve-namespace.js +0 -26
- package/lib/utils.d.ts +0 -8
- package/lib/utils.js +0 -50
package/lib/specs/get-spec.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSpec = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
/**
|
|
6
|
-
* Merging HTML-spec schema and extended spec schemas
|
|
7
|
-
*
|
|
8
|
-
* Ex: `@markuplint/html-spec` + `{ specs: ["@markuplint/vue-spec"] }` in cofigure files.
|
|
9
|
-
*
|
|
10
|
-
* @param schemas `MLDocument.schemas`
|
|
11
|
-
*/
|
|
12
|
-
function getSpec(schemas) {
|
|
13
|
-
var _a, _b, _c;
|
|
14
|
-
const [main, ...extendedSpecs] = schemas;
|
|
15
|
-
const result = { ...main };
|
|
16
|
-
for (const extendedSpec of extendedSpecs) {
|
|
17
|
-
if (extendedSpec.cites) {
|
|
18
|
-
result.cites = [...result.cites, ...extendedSpec.cites];
|
|
19
|
-
}
|
|
20
|
-
if (extendedSpec.def) {
|
|
21
|
-
if (extendedSpec.def['#ariaAttrs']) {
|
|
22
|
-
result.def['#ariaAttrs'] = [...result.def['#ariaAttrs'], ...extendedSpec.def['#ariaAttrs']];
|
|
23
|
-
}
|
|
24
|
-
if ((_a = extendedSpec.def['#globalAttrs']) === null || _a === void 0 ? void 0 : _a['#extends']) {
|
|
25
|
-
result.def['#globalAttrs']['#HTMLGlobalAttrs'] = {
|
|
26
|
-
...(((_b = result.def['#globalAttrs']) === null || _b === void 0 ? void 0 : _b['#HTMLGlobalAttrs']) || {}),
|
|
27
|
-
...(((_c = extendedSpec.def['#globalAttrs']) === null || _c === void 0 ? void 0 : _c['#extends']) || {}),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (extendedSpec.def['#roles']) {
|
|
31
|
-
result.def['#roles'] = [...result.def['#roles'], ...extendedSpec.def['#roles']];
|
|
32
|
-
}
|
|
33
|
-
if (extendedSpec.def['#contentModels']) {
|
|
34
|
-
const keys = new Set([
|
|
35
|
-
...Object.keys(result.def['#contentModels']),
|
|
36
|
-
...Object.keys(extendedSpec.def['#contentModels']),
|
|
37
|
-
]);
|
|
38
|
-
for (const modelName of keys) {
|
|
39
|
-
const mainModel = result.def['#contentModels'][modelName];
|
|
40
|
-
const exModel = extendedSpec.def['#contentModels'][modelName];
|
|
41
|
-
result.def['#contentModels'][modelName] = [...(mainModel || []), ...(exModel || [])];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (extendedSpec.specs) {
|
|
46
|
-
const exSpecs = extendedSpec.specs.slice();
|
|
47
|
-
const specs = [];
|
|
48
|
-
for (const elSpec of result.specs) {
|
|
49
|
-
const tagName = elSpec.name.toLowerCase();
|
|
50
|
-
const index = exSpecs.findIndex(spec => spec.name.toLowerCase() === tagName);
|
|
51
|
-
if (index === -1) {
|
|
52
|
-
specs.push(elSpec);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const exSpec = exSpecs.splice(index, 1)[0];
|
|
56
|
-
specs.push({
|
|
57
|
-
...elSpec,
|
|
58
|
-
...exSpec,
|
|
59
|
-
globalAttrs: {
|
|
60
|
-
...elSpec.globalAttrs,
|
|
61
|
-
...exSpec.globalAttrs,
|
|
62
|
-
},
|
|
63
|
-
attributes: mergeAttrSpec(elSpec.attributes, exSpec.attributes),
|
|
64
|
-
categories: (0, utils_1.mergeArray)(elSpec.categories, exSpec.categories),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
result.specs = specs;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
exports.getSpec = getSpec;
|
|
73
|
-
function mergeAttrSpec(std, ex = {}) {
|
|
74
|
-
const result = {};
|
|
75
|
-
const keys = Array.from(new Set([...Object.keys(std), ...Object.keys(ex)]));
|
|
76
|
-
for (const key of keys) {
|
|
77
|
-
const _std = std[key];
|
|
78
|
-
const _ex = ex[key];
|
|
79
|
-
result[key] = {
|
|
80
|
-
..._std,
|
|
81
|
-
..._ex,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
}
|
package/lib/specs/html-spec.d.ts
DELETED
package/lib/specs/html-spec.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.htmlSpec = void 0;
|
|
4
|
-
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
5
|
-
const cache = new Map();
|
|
6
|
-
function htmlSpec(specs, localName, namespace) {
|
|
7
|
-
const { localNameWithNS } = (0, resolve_namespace_1.resolveNamespace)(localName, namespace || undefined);
|
|
8
|
-
let spec = cache.get(localNameWithNS);
|
|
9
|
-
if (spec !== undefined) {
|
|
10
|
-
return spec;
|
|
11
|
-
}
|
|
12
|
-
spec = specs.specs.find(spec => spec.name === localNameWithNS) || null;
|
|
13
|
-
cache.set(localNameWithNS, spec);
|
|
14
|
-
return spec;
|
|
15
|
-
}
|
|
16
|
-
exports.htmlSpec = htmlSpec;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
2
|
-
declare type NamespacedElementName = {
|
|
3
|
-
localNameWithNS: string;
|
|
4
|
-
localName: string;
|
|
5
|
-
namespace: 'html' | 'svg' | 'mml';
|
|
6
|
-
namespaceURI: NamespaceURI;
|
|
7
|
-
};
|
|
8
|
-
export declare function resolveNamespace(localName: string, namespaceURI?: string): NamespacedElementName;
|
|
9
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveNamespace = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const cache = new Map();
|
|
6
|
-
function resolveNamespace(localName, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
7
|
-
const cached = cache.get(localName + namespaceURI);
|
|
8
|
-
if (cached) {
|
|
9
|
-
return cached;
|
|
10
|
-
}
|
|
11
|
-
const name = localName.split(':')[1] || localName;
|
|
12
|
-
const ns = (0, utils_1.getNS)(namespaceURI || null);
|
|
13
|
-
const result = {
|
|
14
|
-
localNameWithNS: `${ns === 'html' ? '' : `${ns}:`}${name}`,
|
|
15
|
-
localName: name,
|
|
16
|
-
namespace: ns,
|
|
17
|
-
namespaceURI: [
|
|
18
|
-
'http://www.w3.org/1999/xhtml',
|
|
19
|
-
'http://www.w3.org/2000/svg',
|
|
20
|
-
'http://www.w3.org/1998/Math/MathML',
|
|
21
|
-
].find(ns => namespaceURI) || 'http://www.w3.org/1999/xhtml',
|
|
22
|
-
};
|
|
23
|
-
cache.set(localName + namespaceURI, result);
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
exports.resolveNamespace = resolveNamespace;
|
package/lib/utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare type NamedDefinition =
|
|
2
|
-
| string
|
|
3
|
-
| {
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function getNS(namespaceURI: string | null): 'svg' | 'mml' | 'html';
|
|
7
|
-
export declare function mergeArray<T extends NamedDefinition>(a: T[], b: T[] | null | undefined): T[];
|
|
8
|
-
export {};
|
package/lib/utils.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeArray = exports.getNS = void 0;
|
|
4
|
-
function getNS(namespaceURI) {
|
|
5
|
-
switch (namespaceURI) {
|
|
6
|
-
case 'http://www.w3.org/2000/svg': {
|
|
7
|
-
return 'svg';
|
|
8
|
-
}
|
|
9
|
-
case 'http://www.w3.org/1998/Math/MathML': {
|
|
10
|
-
return 'mml';
|
|
11
|
-
}
|
|
12
|
-
default: {
|
|
13
|
-
return 'html';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.getNS = getNS;
|
|
18
|
-
function mergeArray(a, b) {
|
|
19
|
-
if (!b) {
|
|
20
|
-
return a;
|
|
21
|
-
}
|
|
22
|
-
const result = a.slice();
|
|
23
|
-
for (const bItem of b) {
|
|
24
|
-
const bName = getName(bItem);
|
|
25
|
-
const aIndex = result.findIndex(item => getName(item) === bName);
|
|
26
|
-
if (aIndex === -1) {
|
|
27
|
-
result.push(bItem);
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const aItem = result.splice(aIndex, 1)[0];
|
|
31
|
-
if (typeof bItem === 'string') {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (typeof aItem === 'string') {
|
|
35
|
-
result.push(bItem);
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const exItem = {
|
|
39
|
-
...aItem,
|
|
40
|
-
...bItem,
|
|
41
|
-
};
|
|
42
|
-
result.push(exItem);
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
exports.mergeArray = mergeArray;
|
|
47
|
-
function getName(def) {
|
|
48
|
-
const result = typeof def === 'string' ? def : def.name;
|
|
49
|
-
return result.toLowerCase().trim();
|
|
50
|
-
}
|