@markuplint/rules 3.0.0-alpha.66 → 3.0.0-dev.176
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 +10 -44
- package/lib/attr-check.d.ts +22 -10
- package/lib/attr-check.js +32 -23
- package/lib/attr-duplication/index.d.ts +3 -1
- package/lib/attr-duplication/index.js +3 -2
- package/lib/attr-value-quotes/index.d.ts +5 -5
- package/lib/attr-value-quotes/index.js +1 -1
- package/lib/case-sensitive-attr-name/index.d.ts +2 -2
- package/lib/case-sensitive-attr-name/index.js +3 -3
- package/lib/case-sensitive-tag-name/index.d.ts +2 -2
- package/lib/case-sensitive-tag-name/index.js +3 -3
- package/lib/character-reference/index.d.ts +1 -1
- package/lib/character-reference/index.js +1 -1
- package/lib/class-naming/index.d.ts +2 -2
- package/lib/class-naming/index.js +3 -5
- package/lib/create-message.d.ts +13 -2
- package/lib/create-message.js +9 -8
- package/lib/debug.d.ts +1 -1
- package/lib/debug.js +1 -1
- package/lib/deprecated-attr/index.d.ts +3 -1
- package/lib/deprecated-element/index.d.ts +3 -1
- package/lib/deprecated-element/index.js +4 -4
- package/lib/disallowed-element/index.d.ts +1 -1
- package/lib/doctype/index.d.ts +3 -3
- package/lib/doctype/index.js +2 -2
- package/lib/end-tag/index.d.ts +1 -1
- package/lib/end-tag/index.js +3 -18
- package/lib/helpers.d.ts +38 -47
- package/lib/helpers.js +42 -93
- package/lib/id-duplication/index.d.ts +3 -1
- package/lib/index.d.ts +242 -62
- package/lib/index.js +10 -1
- package/lib/ineffective-attr/index.d.ts +3 -1
- package/lib/ineffective-attr/index.js +3 -6
- package/lib/invalid-attr/index.d.ts +40 -12
- package/lib/invalid-attr/index.js +159 -28
- package/lib/label-has-control/index.d.ts +4 -0
- package/lib/label-has-control/index.js +28 -0
- package/lib/landmark-roles/index.d.ts +6 -6
- package/lib/landmark-roles/index.js +10 -6
- package/lib/no-boolean-attr-value/index.d.ts +3 -1
- package/lib/no-boolean-attr-value/index.js +1 -1
- package/lib/no-default-value/index.d.ts +3 -1
- package/lib/no-default-value/index.js +1 -1
- package/lib/no-empty-palpable-content/index.d.ts +6 -0
- package/lib/no-empty-palpable-content/index.js +42 -0
- package/lib/no-hard-code-id/index.d.ts +3 -1
- package/lib/no-hard-code-id/index.js +1 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
- package/lib/no-refer-to-non-existent-id/index.js +65 -5
- package/lib/no-use-event-handler-attr/index.d.ts +3 -3
- package/lib/no-use-event-handler-attr/index.js +6 -6
- package/lib/permitted-contents/choice.d.ts +10 -0
- package/lib/permitted-contents/choice.js +72 -0
- package/lib/permitted-contents/complex-branch.d.ts +20 -0
- package/lib/permitted-contents/complex-branch.js +29 -0
- package/lib/permitted-contents/content-model.d.ts +2 -0
- package/lib/permitted-contents/content-model.js +53 -0
- package/lib/permitted-contents/count-pattern.d.ts +29 -0
- package/lib/permitted-contents/count-pattern.js +162 -0
- package/lib/permitted-contents/debug.browser.d.ts +30 -0
- package/lib/permitted-contents/debug.browser.js +14 -0
- package/lib/permitted-contents/debug.d.ts +3 -0
- package/lib/permitted-contents/debug.js +13 -0
- package/lib/permitted-contents/index.d.ts +2 -8
- package/lib/permitted-contents/index.js +76 -249
- package/lib/permitted-contents/matches-selector.d.ts +8 -0
- package/lib/permitted-contents/matches-selector.js +187 -0
- package/lib/permitted-contents/order.d.ts +20 -0
- package/lib/permitted-contents/order.js +99 -0
- package/lib/permitted-contents/recursive-branch.d.ts +11 -0
- package/lib/permitted-contents/recursive-branch.js +45 -0
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +10 -0
- package/lib/permitted-contents/represent-transparent-nodes.js +78 -0
- package/lib/permitted-contents/start.d.ts +18 -0
- package/lib/permitted-contents/start.js +73 -0
- package/lib/permitted-contents/transparent.d.ts +2 -0
- package/lib/permitted-contents/transparent.js +31 -0
- package/lib/permitted-contents/types.d.ts +52 -0
- package/lib/permitted-contents/types.js +2 -0
- package/lib/permitted-contents/utils.d.ts +100 -0
- package/lib/permitted-contents/utils.js +302 -0
- package/lib/placeholder-label-option/index.d.ts +2 -0
- package/lib/placeholder-label-option/index.js +88 -0
- package/lib/require-accessible-name/index.d.ts +3 -3
- package/lib/require-accessible-name/index.js +12 -4
- package/lib/require-datetime/index.d.ts +6 -0
- package/lib/require-datetime/index.js +34 -0
- package/lib/require-datetime/types.d.ts +10 -0
- package/lib/require-datetime/types.js +2 -0
- package/lib/require-datetime/utils.d.ts +11 -0
- package/lib/require-datetime/utils.js +137 -0
- package/lib/required-attr/index.d.ts +5 -5
- package/lib/required-attr/index.js +20 -17
- package/lib/required-element/index.d.ts +3 -3
- package/lib/required-element/index.js +3 -2
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/required-h1/index.js +4 -3
- package/lib/use-list/index.d.ts +4 -4
- package/lib/use-list/index.js +9 -7
- package/lib/wai-aria/checkings/_.d.ts +15 -0
- package/lib/wai-aria/checkings/_.js +27 -0
- package/lib/wai-aria/checkings/abstract-role.js +1 -1
- package/lib/wai-aria/checkings/default-value.d.ts +7 -3
- package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
- package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
- package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
- package/lib/wai-aria/checkings/implicit-props.js +3 -2
- package/lib/wai-aria/checkings/implicit-role.js +2 -2
- package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +11 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.js +49 -0
- package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
- package/lib/wai-aria/checkings/{non-existant-role.d.ts → non-existent-role.d.ts} +1 -1
- package/lib/wai-aria/checkings/{non-existant-role.js → non-existent-role.js} +4 -4
- package/lib/wai-aria/checkings/permitted-roles.js +1 -1
- package/lib/wai-aria/checkings/presentational-children.d.ts +29 -0
- package/lib/wai-aria/checkings/presentational-children.js +62 -0
- package/lib/wai-aria/checkings/{checking-required-owned-elements.d.ts → required-owned-elements.d.ts} +7 -3
- package/lib/wai-aria/checkings/required-owned-elements.js +103 -0
- package/lib/wai-aria/checkings/required-prop copy.d.ts +15 -0
- package/lib/wai-aria/checkings/required-prop copy.js +27 -0
- package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
- package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +15 -0
- package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
- package/lib/wai-aria/checkings/value.d.ts +19 -4
- package/lib/wai-aria/checkings/value.js +77 -5
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/index.js +27 -16
- package/lib/wai-aria/types.d.ts +11 -9
- package/lib/xxx/index.d.ts +2 -0
- package/lib/xxx/index.js +32 -0
- package/package.json +18 -12
- package/schema.json +12 -0
- package/test/attr-check.spec.js +77 -0
- package/test/attr-duplication/index.spec.js +159 -0
- package/test/attr-value-quotes/index.spec.js +133 -0
- package/test/case-sensitive-attr-name/index.spec.js +65 -0
- package/test/case-sensitive-tag-name/index.spec.js +80 -0
- package/test/character-reference/index.spec.js +57 -0
- package/test/class-naming/index.spec.js +470 -0
- package/test/create-message.spec.js +497 -0
- package/test/deprecated-attr/index.spec.js +48 -0
- package/test/deprecated-element/index.spec.js +48 -0
- package/test/disallowed-element/index.spec.js +90 -0
- package/test/doctype/index.spec.js +50 -0
- package/test/end-tag/index.spec.js +162 -0
- package/test/id-duplication/index.spec.js +47 -0
- package/test/ineffective-attr/index.spec.js +31 -0
- package/test/invalid-attr/index.spec.js +1632 -0
- package/test/label-has-control/index.spec.js +29 -0
- package/test/landmark-roles/index.spec.js +187 -0
- package/test/no-boolean-attr-value/index.spec.js +41 -0
- package/test/no-default-value/index.spec.js +74 -0
- package/test/no-empty-palpable-content/index.spec.js +115 -0
- package/test/no-hard-code-id/index.spec.js +100 -0
- package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
- package/test/no-use-event-handler-attr/index.spec.js +57 -0
- package/test/permitted-contents/choice.spec.js +174 -0
- package/test/permitted-contents/count-pattern.spec.js +308 -0
- package/test/permitted-contents/index.spec.js +1371 -0
- package/test/permitted-contents/matches-selector.spec.js +59 -0
- package/test/permitted-contents/order.spec.js +351 -0
- package/test/permitted-contents/recursive-branch.spec.js +41 -0
- package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
- package/test/permitted-contents/start.spec.js +67 -0
- package/test/placeholder-label-option/index.spec.js +113 -0
- package/test/require-accessible-name/index.spec.js +446 -0
- package/test/require-datetime/index.spec.js +54 -0
- package/test/require-datetime/utils.spec.js +52 -0
- package/test/required-attr/index.spec.js +414 -0
- package/test/required-element/index.spec.js +188 -0
- package/test/required-h1/index.spec.js +69 -0
- package/test/use-list/index.spec.js +109 -0
- package/test/wai-aria/checkings/value.spec.js +33 -0
- package/test/wai-aria/index.spec.js +1173 -0
- package/lib/__foo/index.d.ts +0 -2
- package/lib/__foo/index.js +0 -46
- package/lib/attr-equal-space-after/index.d.ts +0 -3
- package/lib/attr-equal-space-after/index.js +0 -90
- package/lib/attr-equal-space-before/index.d.ts +0 -3
- package/lib/attr-equal-space-before/index.js +0 -90
- package/lib/attr-spacing/index.d.ts +0 -6
- package/lib/attr-spacing/index.js +0 -100
- package/lib/helper/aria/get-aria.d.ts +0 -7
- package/lib/helper/aria/get-aria.js +0 -53
- package/lib/helper/aria/get-computed-role.d.ts +0 -10
- package/lib/helper/aria/get-computed-role.js +0 -24
- package/lib/helper/aria/get-implicit-role.d.ts +0 -7
- package/lib/helper/aria/get-implicit-role.js +0 -12
- package/lib/helper/aria/get-permitted-roles.d.ts +0 -14
- package/lib/helper/aria/get-permitted-roles.js +0 -26
- package/lib/helper/aria/resolve-version.d.ts +0 -2
- package/lib/helper/aria/resolve-version.js +0 -21
- package/lib/helper/spec/aria-spec.d.ts +0 -5
- package/lib/helper/spec/aria-spec.js +0 -12
- package/lib/helper/spec/get-role-spec.d.ts +0 -11
- package/lib/helper/spec/get-role-spec.js +0 -39
- package/lib/helper/spec/html-spec.d.ts +0 -2
- package/lib/helper/spec/html-spec.js +0 -14
- package/lib/indentation/index.d.ts +0 -7
- package/lib/indentation/index.js +0 -208
- package/lib/permitted-contents/array.combination.d.ts +0 -1
- package/lib/permitted-contents/array.combination.js +0 -33
- package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +0 -11
- package/lib/permitted-contents/permitted-content.spec-to-regexp.js +0 -230
- package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +0 -2
- package/lib/permitted-contents/unfold-content-models-to-tags.js +0 -8
- package/lib/wai-aria/checkings/checking-required-owned-elements.js +0 -63
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -6,15 +6,16 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
6
6
|
defaultValue: [],
|
|
7
7
|
async verify({ document, report, t }) {
|
|
8
8
|
await document.walkOn('Element', el => {
|
|
9
|
+
var _a;
|
|
9
10
|
if (el.hasSpreadAttr) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
const customRequiredAttrs = typeof el.rule.value === 'string' ? [el.rule.value] : el.rule.value;
|
|
13
14
|
const attrSpec = (0, ml_core_1.getAttrSpecs)(el, document.specs);
|
|
14
15
|
const attributeSpecs = {};
|
|
15
|
-
if (attrSpec &&
|
|
16
|
+
if (attrSpec && el.elementType === 'html') {
|
|
16
17
|
for (const spec of attrSpec) {
|
|
17
|
-
if (spec.required || spec.requiredEither || spec.condition) {
|
|
18
|
+
if (spec.required != null || spec.requiredEither || spec.condition != null) {
|
|
18
19
|
attributeSpecs[spec.name] = {
|
|
19
20
|
...spec,
|
|
20
21
|
values: [],
|
|
@@ -33,7 +34,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
33
34
|
if (Array.isArray(req.value)) {
|
|
34
35
|
values.push(...req.value);
|
|
35
36
|
}
|
|
36
|
-
else {
|
|
37
|
+
else if (req.value) {
|
|
37
38
|
values.push(req.value);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -53,8 +54,8 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
53
54
|
else if (spec.required === true) {
|
|
54
55
|
invalid = (0, helpers_1.attrMatches)(el, spec.condition) && didntHave;
|
|
55
56
|
}
|
|
56
|
-
else if (spec.required) {
|
|
57
|
-
const selector =
|
|
57
|
+
else if (spec.required != null && spec.required !== false) {
|
|
58
|
+
const selector = typeof spec.required === 'string' ? spec.required : spec.required.join(',');
|
|
58
59
|
invalid = el.matches(selector) && didntHave;
|
|
59
60
|
}
|
|
60
61
|
if (invalid) {
|
|
@@ -65,23 +66,25 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
const value = el.getAttribute(spec.name);
|
|
68
|
-
if (spec.values.length && value) {
|
|
69
|
+
if (spec.values.length > 0 && value) {
|
|
69
70
|
const matched = spec.values.some(pattern => (0, helpers_1.match)(value, pattern));
|
|
70
71
|
if (!matched) {
|
|
71
72
|
const expects = spec.values.length === 1 ? t(spec.values) : t('either {0}', t(spec.values));
|
|
72
73
|
const message = t('{0} expects {1}', t('the "{0*}" {1}', spec.name, 'attribute'), expects);
|
|
73
74
|
const attrToken = el.getAttributeToken(spec.name);
|
|
74
|
-
const valueToken = attrToken[0].valueNode;
|
|
75
|
-
const token = valueToken
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
const valueToken = (_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.valueNode;
|
|
76
|
+
const token = valueToken !== null && valueToken !== void 0 ? valueToken : attrToken[0];
|
|
77
|
+
if (token) {
|
|
78
|
+
report({
|
|
79
|
+
scope: {
|
|
80
|
+
rule: el.rule,
|
|
81
|
+
raw: token.raw,
|
|
82
|
+
startCol: token.startCol,
|
|
83
|
+
startLine: token.startLine,
|
|
84
|
+
},
|
|
85
|
+
message,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Options = {
|
|
2
|
+
ignoreHasMutableContents: boolean;
|
|
3
3
|
};
|
|
4
|
-
declare const _default: import(
|
|
4
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<string[], Options>>;
|
|
5
5
|
export default _default;
|
|
@@ -7,6 +7,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
7
7
|
ignoreHasMutableContents: true,
|
|
8
8
|
},
|
|
9
9
|
async verify({ document, report, t }) {
|
|
10
|
+
var _a, _b;
|
|
10
11
|
const hasMutableContent = document.nodeList.some(n => n.is(n.ELEMENT_NODE) && n.hasMutableChildren());
|
|
11
12
|
if (!hasMutableContent) {
|
|
12
13
|
for (const query of document.rule.value) {
|
|
@@ -17,7 +18,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
17
18
|
message,
|
|
18
19
|
line: 1,
|
|
19
20
|
col: 1,
|
|
20
|
-
raw: document.nodeList[0].raw.slice(0, 1),
|
|
21
|
+
raw: (_b = (_a = document.nodeList[0]) === null || _a === void 0 ? void 0 : _a.raw.slice(0, 1)) !== null && _b !== void 0 ? _b : '',
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -26,7 +27,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
26
27
|
if (el.rule.value === document.rule.value) {
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
if (el.rule.
|
|
30
|
+
if (el.rule.options.ignoreHasMutableContents && el.hasMutableChildren()) {
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
for (const query of el.rule.value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Options {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
'expected-once': boolean;
|
|
3
|
+
'in-document-fragment': boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: import(
|
|
5
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Options>>;
|
|
6
6
|
export default _default;
|
package/lib/required-h1/index.js
CHANGED
|
@@ -7,11 +7,12 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
7
7
|
'in-document-fragment': false,
|
|
8
8
|
},
|
|
9
9
|
async verify({ document, report, t }) {
|
|
10
|
+
var _a, _b;
|
|
10
11
|
const h1Stack = [];
|
|
11
12
|
if (document.nodeList.length === 0) {
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
|
-
if (!document.rule.
|
|
15
|
+
if (!document.rule.options['in-document-fragment'] && document.isFragment) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
await document.walkOn('Element', node => {
|
|
@@ -25,10 +26,10 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
25
26
|
message,
|
|
26
27
|
line: 1,
|
|
27
28
|
col: 1,
|
|
28
|
-
raw: document.nodeList[0].raw.slice(0, 1),
|
|
29
|
+
raw: (_b = (_a = document.nodeList[0]) === null || _a === void 0 ? void 0 : _a.raw.slice(0, 1)) !== null && _b !== void 0 ? _b : '',
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
|
-
else if (document.rule.
|
|
32
|
+
else if (document.rule.options['expected-once'] && h1Stack.length > 1 && h1Stack[1]) {
|
|
32
33
|
const message = t('{0} is {1:c}', t('the "{0*}" {1}', 'h1', 'element'), 'duplicated');
|
|
33
34
|
report({
|
|
34
35
|
message,
|
package/lib/use-list/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type Bullets = readonly string[];
|
|
2
|
+
type Options = {
|
|
3
|
+
spaceNeededBullets?: string[];
|
|
4
4
|
};
|
|
5
|
-
declare const _default: import(
|
|
5
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Bullets, Options>>;
|
|
6
6
|
export default _default;
|
package/lib/use-list/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
const
|
|
4
|
+
const shared_1 = require("@markuplint/shared");
|
|
5
5
|
exports.default = (0, ml_core_1.createRule)({
|
|
6
6
|
defaultValue: [
|
|
7
7
|
/**
|
|
@@ -54,12 +54,13 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
54
54
|
'+', // plus signs
|
|
55
55
|
],
|
|
56
56
|
},
|
|
57
|
-
|
|
57
|
+
defaultSeverity: 'warning',
|
|
58
58
|
async verify({ document, report, t }) {
|
|
59
59
|
await document.walkOn('Text', textNode => {
|
|
60
|
-
|
|
60
|
+
var _a;
|
|
61
|
+
const text = (0, shared_1.decodeEntities)(textNode.raw.trim());
|
|
61
62
|
if (!text) {
|
|
62
|
-
//
|
|
63
|
+
// empty
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
if (text.length === 1) {
|
|
@@ -67,7 +68,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
const bullets = textNode.rule.value;
|
|
70
|
-
const spaceNeededBullets = textNode.rule.
|
|
71
|
+
const spaceNeededBullets = (_a = textNode.rule.options.spaceNeededBullets) !== null && _a !== void 0 ? _a : [];
|
|
71
72
|
if (isMayListItem(text, bullets, spaceNeededBullets)) {
|
|
72
73
|
report({
|
|
73
74
|
scope: textNode,
|
|
@@ -78,15 +79,16 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
78
79
|
},
|
|
79
80
|
});
|
|
80
81
|
function isMayListItem(text, bullets, spaceNeededBullets) {
|
|
82
|
+
var _a;
|
|
81
83
|
const textArray = Array.from(text);
|
|
82
|
-
const firstLetter = textArray[0];
|
|
84
|
+
const firstLetter = (_a = textArray[0]) !== null && _a !== void 0 ? _a : '';
|
|
83
85
|
const isBullet = bullets.includes(firstLetter);
|
|
84
86
|
const needSpace = spaceNeededBullets.includes(firstLetter);
|
|
85
87
|
const continuous = firstLetter === textArray[1];
|
|
86
88
|
if (continuous) {
|
|
87
89
|
return false;
|
|
88
90
|
}
|
|
89
|
-
if (isBullet && needSpace) {
|
|
91
|
+
if (isBullet && needSpace && text[1]) {
|
|
90
92
|
const secondLetter = text[1];
|
|
91
93
|
const isSpace = /^\s$/.test(secondLetter);
|
|
92
94
|
return isSpace;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
export declare const checkingRequiredProp: ElementChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role?:
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
isImplicit?: boolean;
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
13
|
+
propSpecs: readonly ARIAProperty[];
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingRequiredProp = void 0;
|
|
4
|
+
const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!role) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (role.isImplicit) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const requiredProps = role.ownedProperties.filter(s => s.required).map(s => s.name);
|
|
13
|
+
for (const requiredProp of requiredProps) {
|
|
14
|
+
const has = el.attributes.some(attr => {
|
|
15
|
+
const attrName = attr.name.toLowerCase();
|
|
16
|
+
return attrName === requiredProp;
|
|
17
|
+
});
|
|
18
|
+
if (!has) {
|
|
19
|
+
const propSpec = propSpecs.find(p => p.name === requiredProp);
|
|
20
|
+
return {
|
|
21
|
+
scope: el,
|
|
22
|
+
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`)), t('the "{0*}" {1}', role.name, 'role')),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.checkingRequiredProp = checkingRequiredProp;
|
|
@@ -4,7 +4,7 @@ exports.checkingAbstractRole = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const checkingAbstractRole = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
|
-
const { roles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.
|
|
7
|
+
const { roles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.options.version);
|
|
8
8
|
const tokens = (_a = attr.tokenList) === null || _a === void 0 ? void 0 : _a.allTokens();
|
|
9
9
|
if (!tokens) {
|
|
10
10
|
return;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingDefaultValue: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const checkingDefaultValue: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
}
|
|
10
|
+
>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingDeprecatedProps: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const checkingDeprecatedProps: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role: ARIARole | null;
|
|
9
|
+
propSpecs: readonly ARIAProperty[];
|
|
10
|
+
}
|
|
11
|
+
>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingDisallowedProp: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const checkingDisallowedProp: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role: ARIARole | null;
|
|
9
|
+
propSpecs: readonly ARIAProperty[];
|
|
10
|
+
}
|
|
11
|
+
>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkingDisallowedProp = void 0;
|
|
4
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
4
5
|
const checkingDisallowedProp = ({ attr, role, propSpecs }) => t => {
|
|
5
|
-
var _a;
|
|
6
|
+
var _a, _b, _c, _d;
|
|
6
7
|
if (!role) {
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
@@ -10,13 +11,36 @@ const checkingDisallowedProp = ({ attr, role, propSpecs }) => t => {
|
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
const statesAndProp = role.ownedProperties.find(p => p.name === attr.name);
|
|
14
|
+
const propSpec = propSpecs.find(p => p.name === attr.name);
|
|
15
|
+
const elAriaSpec = (0, ml_spec_1.getARIA)(attr.ownerMLDocument.specs, attr.ownerElement.localName, attr.ownerElement.namespaceURI, attr.rule.options.version, attr.ownerElement.matches.bind(attr.ownerElement));
|
|
16
|
+
if ((elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) !== false && ((_a = elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) === null || _a === void 0 ? void 0 : _a.without)) {
|
|
17
|
+
for (const ignore of elAriaSpec.properties.without) {
|
|
18
|
+
if (ignore.name === attr.name) {
|
|
19
|
+
return {
|
|
20
|
+
scope: attr,
|
|
21
|
+
message: t('{0:c} on {1}', t(ignore.type === 'must-not'
|
|
22
|
+
? '{0} must not {1}'
|
|
23
|
+
: ignore.type === 'should-not'
|
|
24
|
+
? '{0} should not {1}'
|
|
25
|
+
: '{0} is not recommended to {1}',
|
|
26
|
+
// {0}
|
|
27
|
+
t('the "{0*}" {1}', attr.name, `ARIA ${(_b = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _b !== void 0 ? _b : 'property'}`),
|
|
28
|
+
// {1}
|
|
29
|
+
'use'), t('the "{0*}" {1}', attr.ownerElement.localName, 'element')) +
|
|
30
|
+
(ignore.alt
|
|
31
|
+
? t('. ') +
|
|
32
|
+
t('{0} if you {1} {2}', t(ignore.alt.method === 'remove-attr' ? 'Remove {0}' : 'Add {0}', t('the "{0*}" {1}', ignore.alt.target, 'attribute')), 'use', t('the {0}', `ARIA ${(_c = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _c !== void 0 ? _c : 'property'}`))
|
|
33
|
+
: ''),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
13
38
|
if (statesAndProp) {
|
|
14
39
|
return;
|
|
15
40
|
}
|
|
16
|
-
const propSpec = propSpecs.find(p => p.name === attr.name);
|
|
17
41
|
return {
|
|
18
42
|
scope: attr,
|
|
19
|
-
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0*}" {1}', attr.name, `ARIA ${(
|
|
43
|
+
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0*}" {1}', attr.name, `ARIA ${(_d = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _d !== void 0 ? _d : 'property'}`), 'disallowed'), t('the "{0*}" {1}', role.name, 'role')),
|
|
20
44
|
};
|
|
21
45
|
};
|
|
22
46
|
exports.checkingDisallowedProp = checkingDisallowedProp;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, Attribute } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingImplicitProps: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const checkingImplicitProps: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
attrSpecs: readonly Attribute[] | null;
|
|
10
|
+
}
|
|
11
|
+
>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.checkingImplicitProps = void 0;
|
|
4
4
|
const helpers_1 = require("../../helpers");
|
|
5
5
|
const checkingImplicitProps = ({ attr, propSpecs, attrSpecs }) => t => {
|
|
6
|
+
var _a;
|
|
6
7
|
if (!attrSpecs) {
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
@@ -15,8 +16,8 @@ const checkingImplicitProps = ({ attr, propSpecs, attrSpecs }) => t => {
|
|
|
15
16
|
}
|
|
16
17
|
for (const equivalentHtmlAttr of propSpec.equivalentHtmlAttrs) {
|
|
17
18
|
const htmlAttrSpec = attrSpecs.find(a => a.name === equivalentHtmlAttr.htmlAttrName);
|
|
18
|
-
const isValid = (0, helpers_1.isValidAttr)(t, equivalentHtmlAttr.htmlAttrName, equivalentHtmlAttr.value
|
|
19
|
-
if (isValid && isValid.invalidType === 'non-existent') {
|
|
19
|
+
const isValid = (0, helpers_1.isValidAttr)(t, equivalentHtmlAttr.htmlAttrName, (_a = equivalentHtmlAttr.value) !== null && _a !== void 0 ? _a : '', false, attr.ownerElement, attrSpecs);
|
|
20
|
+
if (isValid !== false && isValid.invalidType === 'non-existent') {
|
|
20
21
|
continue;
|
|
21
22
|
}
|
|
22
23
|
const value = attr.value.trim().toLowerCase();
|
|
@@ -4,13 +4,13 @@ exports.checkingImplicitRole = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const checkingImplicitRole = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
|
-
const
|
|
7
|
+
const implicitRole = (0, ml_spec_1.getImplicitRoleName)(attr.ownerElement, attr.rule.options.version, attr.ownerMLDocument.specs);
|
|
8
8
|
const tokens = (_a = attr.tokenList) === null || _a === void 0 ? void 0 : _a.allTokens();
|
|
9
9
|
if (!tokens) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
for (const token of tokens) {
|
|
13
|
-
if (
|
|
13
|
+
if (implicitRole === token.raw) {
|
|
14
14
|
return {
|
|
15
15
|
scope: token,
|
|
16
16
|
message: t('{0} is {1}', t('the "{0*}" {1}', token.raw, 'role'), t('{0} of {1}', 'the implicit role', t('the "{0*}" {1}', attr.ownerElement.localName, 'element'))),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
/**
|
|
4
|
+
* Including Elements in the Accessibility Tree
|
|
5
|
+
*
|
|
6
|
+
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
7
|
+
* > Elements that are not hidden and may fire an accessibility API event, including:
|
|
8
|
+
* > - Elements that are currently focused, even if the element or one of its ancestor elements has its aria-hidden attribute set to true.
|
|
9
|
+
* > - Elements that are a valid target of an aria-activedescendant attribute.
|
|
10
|
+
*/
|
|
11
|
+
export declare const checkingInteractionInHidden: ElementChecker<boolean, Options>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingInteractionInHidden = void 0;
|
|
4
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
|
+
/**
|
|
6
|
+
* Including Elements in the Accessibility Tree
|
|
7
|
+
*
|
|
8
|
+
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
9
|
+
* > Elements that are not hidden and may fire an accessibility API event, including:
|
|
10
|
+
* > - Elements that are currently focused, even if the element or one of its ancestor elements has its aria-hidden attribute set to true.
|
|
11
|
+
* > - Elements that are a valid target of an aria-activedescendant attribute.
|
|
12
|
+
*/
|
|
13
|
+
// フォーカスがあたっている場合に限り、先祖がaria-hidden=trueでもアクセシビリティツリーに提示される
|
|
14
|
+
// なので、aria-hidden=trueの子孫要素で且つインタラクティブ要素である場合、
|
|
15
|
+
// それは開発者にとってはほとんどの場合、意図しないことが多いはずなので、
|
|
16
|
+
// 仕様上不正にはならないが、十分に注意しなければならない状態である。
|
|
17
|
+
const checkingInteractionInHidden = ({ el }) => t => {
|
|
18
|
+
if (!(0, ml_spec_1.mayBeFocusable)(el, el.ownerMLDocument.specs)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const ariaHidden = getClosestAriaHidden(el);
|
|
22
|
+
if (!ariaHidden) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (el === ariaHidden.ownerElement) {
|
|
26
|
+
return {
|
|
27
|
+
scope: el,
|
|
28
|
+
message: t('It may be focusable in spite of it has aria-hidden=true'),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
scope: el,
|
|
33
|
+
message: t('It may be focusable in spite of it has the ancestor that has aria-hidden=true'),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.checkingInteractionInHidden = checkingInteractionInHidden;
|
|
37
|
+
function getClosestAriaHidden(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
39
|
+
el) {
|
|
40
|
+
let current = el;
|
|
41
|
+
while (current) {
|
|
42
|
+
const ariaHidden = current.getAttributeNode('aria-hidden');
|
|
43
|
+
if ((ariaHidden === null || ariaHidden === void 0 ? void 0 : ariaHidden.value) === 'true') {
|
|
44
|
+
return ariaHidden;
|
|
45
|
+
}
|
|
46
|
+
current = current.parentElement;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingNoGlobalProp: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const checkingNoGlobalProp: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
}
|
|
10
|
+
>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.checkingNonExistentRole = void 0;
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
|
-
const
|
|
5
|
+
const checkingNonExistentRole = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
|
-
const { roles, graphicsRoles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.
|
|
7
|
+
const { roles, graphicsRoles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.options.version);
|
|
8
8
|
const tokens = (_a = attr.tokenList) === null || _a === void 0 ? void 0 : _a.allTokens();
|
|
9
9
|
if (!tokens) {
|
|
10
10
|
return;
|
|
@@ -25,4 +25,4 @@ const checkingNonExistantRole = ({ attr }) => t => {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
exports.
|
|
28
|
+
exports.checkingNonExistentRole = checkingNonExistentRole;
|
|
@@ -5,7 +5,7 @@ const ml_spec_1 = require("@markuplint/ml-spec");
|
|
|
5
5
|
const checkingPermittedRoles = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
7
|
const el = attr.ownerElement;
|
|
8
|
-
const permittedRoles = (0, ml_spec_1.getPermittedRoles)(el, el.rule.
|
|
8
|
+
const permittedRoles = (0, ml_spec_1.getPermittedRoles)(el, el.rule.options.version, attr.ownerMLDocument.specs);
|
|
9
9
|
if (permittedRoles.length === 0) {
|
|
10
10
|
return {
|
|
11
11
|
scope: attr,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
/**
|
|
4
|
+
* Presentational Children
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.w3.org/TR/wai-aria/#childrenArePresentational
|
|
7
|
+
* @see https://w3c.github.io/aria/#childrenArePresentational
|
|
8
|
+
*
|
|
9
|
+
* > The DOM descendants are presentational.
|
|
10
|
+
* > user agents SHOULD NOT expose descendants of
|
|
11
|
+
* > this element through the platform accessibility API.
|
|
12
|
+
* > If user agents do not hide the descendant nodes,
|
|
13
|
+
* > some information may be read twice.
|
|
14
|
+
*
|
|
15
|
+
* @see https://w3c.github.io/aria/#tree_exclusion
|
|
16
|
+
*
|
|
17
|
+
* > Any descendants of elements that have the characteristic "Children Presentational: True"
|
|
18
|
+
* > unless the descendant is not allowed to be presentational
|
|
19
|
+
* > because it meets one of the conditions for exception described
|
|
20
|
+
* > in Presentational Roles Conflict Resolution.
|
|
21
|
+
* > However, the text content of any excluded descendants is included.
|
|
22
|
+
*
|
|
23
|
+
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
24
|
+
*
|
|
25
|
+
* > Text equivalents for hidden referenced objects
|
|
26
|
+
* > may still be used in the name and description computation
|
|
27
|
+
* > even when not included in the accessibility tree.
|
|
28
|
+
*/
|
|
29
|
+
export declare const checkingPresentationalChildren: ElementChecker<boolean, Options>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingPresentationalChildren = void 0;
|
|
4
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
|
+
/**
|
|
6
|
+
* Presentational Children
|
|
7
|
+
*
|
|
8
|
+
* @see https://www.w3.org/TR/wai-aria/#childrenArePresentational
|
|
9
|
+
* @see https://w3c.github.io/aria/#childrenArePresentational
|
|
10
|
+
*
|
|
11
|
+
* > The DOM descendants are presentational.
|
|
12
|
+
* > user agents SHOULD NOT expose descendants of
|
|
13
|
+
* > this element through the platform accessibility API.
|
|
14
|
+
* > If user agents do not hide the descendant nodes,
|
|
15
|
+
* > some information may be read twice.
|
|
16
|
+
*
|
|
17
|
+
* @see https://w3c.github.io/aria/#tree_exclusion
|
|
18
|
+
*
|
|
19
|
+
* > Any descendants of elements that have the characteristic "Children Presentational: True"
|
|
20
|
+
* > unless the descendant is not allowed to be presentational
|
|
21
|
+
* > because it meets one of the conditions for exception described
|
|
22
|
+
* > in Presentational Roles Conflict Resolution.
|
|
23
|
+
* > However, the text content of any excluded descendants is included.
|
|
24
|
+
*
|
|
25
|
+
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
26
|
+
*
|
|
27
|
+
* > Text equivalents for hidden referenced objects
|
|
28
|
+
* > may still be used in the name and description computation
|
|
29
|
+
* > even when not included in the accessibility tree.
|
|
30
|
+
*/
|
|
31
|
+
const checkingPresentationalChildren = ({ el }) => t => {
|
|
32
|
+
const ancestor = getAncestorHasPresentationalChildren(el);
|
|
33
|
+
if (!ancestor) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!ancestor.role) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const hasAriaAttr = Array.from(el.attributes).some(attr => /^aria-|^role$/i.test(attr.name));
|
|
40
|
+
if (!hasAriaAttr) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
scope: el,
|
|
45
|
+
message: t('it may be ineffective because {0}', t("it has {0} as an ancestor that doesn't expose its descendants to the accessibility tree", t('the "{0*}" {1}', ancestor.role.name, 'role'))),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.checkingPresentationalChildren = checkingPresentationalChildren;
|
|
49
|
+
function getAncestorHasPresentationalChildren(
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
51
|
+
el) {
|
|
52
|
+
var _a;
|
|
53
|
+
let current = el.parentElement;
|
|
54
|
+
while (current) {
|
|
55
|
+
const computed = (0, ml_spec_1.getComputedRole)(el.ownerMLDocument.specs, current, el.rule.options.version);
|
|
56
|
+
if ((_a = computed.role) === null || _a === void 0 ? void 0 : _a.childrenPresentational) {
|
|
57
|
+
return computed;
|
|
58
|
+
}
|
|
59
|
+
current = current.parentElement;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
@@ -6,6 +6,10 @@ import type { ARIARole } from '@markuplint/ml-spec';
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://w3c.github.io/aria/#mustContain
|
|
8
8
|
*/
|
|
9
|
-
export declare const checkingRequiredOwnedElements: ElementChecker<
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export declare const checkingRequiredOwnedElements: ElementChecker<
|
|
10
|
+
boolean,
|
|
11
|
+
Options,
|
|
12
|
+
{
|
|
13
|
+
role?: ARIARole | null;
|
|
14
|
+
}
|
|
15
|
+
>;
|