From 2416ed338ca704223785b4be7e68173babbbc54c Mon Sep 17 00:00:00 2001 From: Paul Grenier Date: Fri, 24 May 2019 11:08:40 -0400 Subject: [PATCH] feat(role-img-alt): Split rule for role=img with no accessible name (#1586) --- doc/rule-descriptions.md | 1 + lib/rules/image-alt.json | 2 +- lib/rules/role-img-alt.json | 18 ++++++++++++++++++ .../integration/rules/image-alt/image-alt.html | 5 +---- .../integration/rules/image-alt/image-alt.json | 6 ++---- .../rules/role-img-alt/role-img-alt.html | 13 +++++++++++++ .../rules/role-img-alt/role-img-alt.json | 12 ++++++++++++ 7 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 lib/rules/role-img-alt.json create mode 100644 test/integration/rules/role-img-alt/role-img-alt.html create mode 100644 test/integration/rules/role-img-alt/role-img-alt.json diff --git a/doc/rule-descriptions.md b/doc/rule-descriptions.md index 987b0fa0f2..527f42c8c8 100644 --- a/doc/rule-descriptions.md +++ b/doc/rule-descriptions.md @@ -66,6 +66,7 @@ | page-has-heading-one | Ensure that the page, or at least one of its frames contains a level-one heading | Moderate | cat.semantics, best-practice | true | | radiogroup | Ensures related <input type="radio"> elements have a group and that the group designation is consistent | Critical | cat.forms, best-practice | true | | region | Ensures all page content is contained by landmarks | Moderate | cat.keyboard, best-practice | true | +| role-img-alt | Ensures [role='img'] elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true | | scope-attr-valid | Ensures the scope attribute is used correctly on tables | Moderate, Critical | cat.tables, best-practice | true | | scrollable-region-focusable | Elements that have scrollable content should be accessible by keyboard | Moderate | wcag2a, wcag211 | true | | server-side-image-map | Ensures that server-side image maps are not used | Minor | cat.text-alternatives, wcag2a, wcag211, section508, section508.22.f | true | diff --git a/lib/rules/image-alt.json b/lib/rules/image-alt.json index 1b4791e31d..4738b3629a 100644 --- a/lib/rules/image-alt.json +++ b/lib/rules/image-alt.json @@ -1,6 +1,6 @@ { "id": "image-alt", - "selector": "img, [role='img']:not(svg)", + "selector": "img", "tags": [ "cat.text-alternatives", "wcag2a", diff --git a/lib/rules/role-img-alt.json b/lib/rules/role-img-alt.json new file mode 100644 index 0000000000..49ec8eaabe --- /dev/null +++ b/lib/rules/role-img-alt.json @@ -0,0 +1,18 @@ +{ + "id": "role-img-alt", + "selector": "[role='img']:not(svg):not(img):not(area):not(input):not(object)", + "tags": [ + "cat.text-alternatives", + "wcag2a", + "wcag111", + "section508", + "section508.22.a" + ], + "metadata": { + "description": "Ensures [role='img'] elements have alternate text", + "help": "[role='img'] elements have an alternative text" + }, + "all": [], + "any": ["aria-label", "aria-labelledby", "non-empty-title"], + "none": [] +} diff --git a/test/integration/rules/image-alt/image-alt.html b/test/integration/rules/image-alt/image-alt.html index 933f081d3a..f543da13c7 100644 --- a/test/integration/rules/image-alt/image-alt.html +++ b/test/integration/rules/image-alt/image-alt.html @@ -13,7 +13,4 @@ - - - -SVG Title + diff --git a/test/integration/rules/image-alt/image-alt.json b/test/integration/rules/image-alt/image-alt.json index 8fe3368f91..807d5542cd 100644 --- a/test/integration/rules/image-alt/image-alt.json +++ b/test/integration/rules/image-alt/image-alt.json @@ -7,8 +7,7 @@ ["#violation3"], ["#violation4"], ["#violation5"], - ["#violation6"], - ["#violation7"] + ["#violation6"] ], "passes": [ ["#pass1"], @@ -18,7 +17,6 @@ ["#pass5"], ["#pass6"], ["#pass7"], - ["#pass8"], - ["#pass9"] + ["#pass8"] ] } diff --git a/test/integration/rules/role-img-alt/role-img-alt.html b/test/integration/rules/role-img-alt/role-img-alt.html new file mode 100644 index 0000000000..8edbb4801b --- /dev/null +++ b/test/integration/rules/role-img-alt/role-img-alt.html @@ -0,0 +1,13 @@ +
Bananas
+ + + + + + + + + + + + diff --git a/test/integration/rules/role-img-alt/role-img-alt.json b/test/integration/rules/role-img-alt/role-img-alt.json new file mode 100644 index 0000000000..6045d6aafb --- /dev/null +++ b/test/integration/rules/role-img-alt/role-img-alt.json @@ -0,0 +1,12 @@ +{ + "description": "role-img-alt tests", + "rule": "role-img-alt", + "violations": [ + ["#violation1"], + ["#violation2"], + ["#violation3"], + ["#violation4"], + ["#violation5"] + ], + "passes": [["#pass1"], ["#pass2"], ["#pass3"], ["#pass4"]] +}