diff --git a/doc/rule-descriptions.md b/doc/rule-descriptions.md index 1d844bfb36..9e7759a5f9 100644 --- a/doc/rule-descriptions.md +++ b/doc/rule-descriptions.md @@ -82,6 +82,7 @@ Rules that do not necessarily conform to WCAG success criterion but are industry | [accesskeys](https://dequeuniversity.com/rules/axe/4.1/accesskeys?application=RuleDescription) | Ensures every accesskey attribute value is unique | Serious | cat.keyboard, best-practice | failure | | [aria-allowed-role](https://dequeuniversity.com/rules/axe/4.1/aria-allowed-role?application=RuleDescription) | Ensures role attribute has an appropriate value for the element | Minor | cat.aria, best-practice | failure, needs review | | [aria-dialog-name](https://dequeuniversity.com/rules/axe/4.1/aria-dialog-name?application=RuleDescription) | Ensures every ARIA dialog and alertdialog node has an accessible name | Serious | cat.aria, best-practice | failure, needs review | +| [aria-text](https://dequeuniversity.com/rules/axe/4.1/aria-text?application=RuleDescription) | Ensures "role=text" is used correctly | Serious | cat.aria, best-practice | failure, needs review | | [aria-treeitem-name](https://dequeuniversity.com/rules/axe/4.1/aria-treeitem-name?application=RuleDescription) | Ensures every ARIA treeitem node has an accessible name | Serious | cat.aria, best-practice | failure, needs review | | [empty-heading](https://dequeuniversity.com/rules/axe/4.1/empty-heading?application=RuleDescription) | Ensures headings have discernible text | Minor | cat.name-role-value, best-practice | failure, needs review | | [frame-tested](https://dequeuniversity.com/rules/axe/4.1/frame-tested?application=RuleDescription) | Ensures <iframe> and <frame> elements contain the axe-core script | Critical | cat.structure, review-item, best-practice | failure, needs review | diff --git a/lib/rules/aria-text.json b/lib/rules/aria-text.json new file mode 100644 index 0000000000..aa284a5867 --- /dev/null +++ b/lib/rules/aria-text.json @@ -0,0 +1,12 @@ +{ + "id": "aria-text", + "selector": "[role=text]", + "tags": ["cat.aria", "best-practice"], + "metadata": { + "description": "Ensures \"role=text\" is used on elements with no focusable descendants", + "help": "\"role=text\" should have no focusable descendants" + }, + "all": [], + "any": ["no-focusable-content"], + "none": [] +} diff --git a/lib/standards/aria-roles.js b/lib/standards/aria-roles.js index 6b1ac245d8..aa572103b0 100644 --- a/lib/standards/aria-roles.js +++ b/lib/standards/aria-roles.js @@ -719,6 +719,11 @@ const ariaRoles = { // Note: spec difference nameFromContent: true }, + text: { + type: 'structure', + superclassRole: ['section'], + nameFromContent: true + }, textbox: { type: 'widget', allowedAttrs: [ diff --git a/test/commons/standards/get-aria-roles-by-type.js b/test/commons/standards/get-aria-roles-by-type.js index 012a319c6a..c7da0b3515 100644 --- a/test/commons/standards/get-aria-roles-by-type.js +++ b/test/commons/standards/get-aria-roles-by-type.js @@ -47,6 +47,7 @@ describe('standards.getAriaRolesByType', function() { 'superscript', 'table', 'term', + 'text', 'time', 'toolbar', 'tooltip' diff --git a/test/commons/standards/get-aria-roles-supporting-name-from-content.js b/test/commons/standards/get-aria-roles-supporting-name-from-content.js index 525e279aee..4e1af1ee4f 100644 --- a/test/commons/standards/get-aria-roles-supporting-name-from-content.js +++ b/test/commons/standards/get-aria-roles-supporting-name-from-content.js @@ -43,6 +43,7 @@ describe('standards.getAriaRolesSupportingNameFromContent', function() { 'tab', 'table', 'term', + 'text', 'tooltip', 'treeitem', 'doc-backlink', diff --git a/test/integration/rules/aria-allowed-role/aria-allowed-role.html b/test/integration/rules/aria-allowed-role/aria-allowed-role.html index 63c319d006..5185019996 100644 --- a/test/integration/rules/aria-allowed-role/aria-allowed-role.html +++ b/test/integration/rules/aria-allowed-role/aria-allowed-role.html @@ -169,6 +169,9 @@


+ +
+

@@ -212,3 +215,7 @@

ok
ok
+

ok

+ +ok +
ok
diff --git a/test/integration/rules/aria-allowed-role/aria-allowed-role.json b/test/integration/rules/aria-allowed-role/aria-allowed-role.json index 309e83f03b..72e58f1425 100644 --- a/test/integration/rules/aria-allowed-role/aria-allowed-role.json +++ b/test/integration/rules/aria-allowed-role/aria-allowed-role.json @@ -66,7 +66,10 @@ ["#pass-dpub-6"], ["#pass-dpub-7"], ["#hr-presentation"], - ["#hr-none"] + ["#hr-none"], + ["#span-text"], + ["#div-text"], + ["#p-text"] ], "violations": [ ["#fail-dd-no-role"], @@ -88,7 +91,11 @@ ["#fail-dpub-4"], ["#fail-dpub-5"], ["#fail-dpub-6"], - ["#fail-dpub-7"] + ["#fail-dpub-7"], + ["#fail-text-1"], + ["#fail-text-2"], + ["#fail-text-3"], + ["#fail-text-4"] ], "incomplete": [["#incomplete1"], ["#incomplete2"]] } diff --git a/test/integration/rules/aria-roles/aria-roles.html b/test/integration/rules/aria-roles/aria-roles.html index bb7a8e42d4..9814b19ecf 100644 --- a/test/integration/rules/aria-roles/aria-roles.html +++ b/test/integration/rules/aria-roles/aria-roles.html @@ -107,6 +107,7 @@
ok
ok
ok
+
ok
@@ -124,10 +125,9 @@
fail
fail
-
ok
-
fail
+
fail
diff --git a/test/integration/rules/aria-roles/aria-roles.json b/test/integration/rules/aria-roles/aria-roles.json index d2f7c672b0..26fb619397 100644 --- a/test/integration/rules/aria-roles/aria-roles.json +++ b/test/integration/rules/aria-roles/aria-roles.json @@ -15,8 +15,7 @@ ["#fail11"], ["#fail12"], ["#fail13"], - ["#fail14"], - ["#fail15"] + ["#fail14"] ], "passes": [ ["#pass1"], @@ -126,6 +125,7 @@ ["#pass106"], ["#pass107"], ["#pass108"], - ["#pass109"] + ["#pass109"], + ["#pass110"] ] } diff --git a/test/integration/rules/aria-text/aria-text.html b/test/integration/rules/aria-text/aria-text.html new file mode 100644 index 0000000000..28252c0bce --- /dev/null +++ b/test/integration/rules/aria-text/aria-text.html @@ -0,0 +1,22 @@ +

+ Digital accessibility,
+ for everyone. +
+

+Buy t-shirts now +
Some text and some more text
+ +
+ Still an interactive link because of the author error. +
+
+ Flattened text because of the explicit role. +
+
+ Flattened text because of the + explicit role. +
+

diff --git a/test/integration/rules/aria-text/aria-text.json b/test/integration/rules/aria-text/aria-text.json new file mode 100644 index 0000000000..f6c3f1d2d9 --- /dev/null +++ b/test/integration/rules/aria-text/aria-text.json @@ -0,0 +1,6 @@ +{ + "description": "aria-text tests", + "rule": "aria-text", + "violations": [["#fail1"], ["#fail2"], ["#fail3"], ["#fail4"]], + "passes": [["#pass1"], ["#pass2"], ["#pass3"]] +}