Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aria-allowed-role): allow title, aria-label and aria-labelledby on a img element with a supported role #3224

Merged
merged 14 commits into from
Nov 10, 2021

Conversation

Zidious
Copy link
Contributor

@Zidious Zidious commented Oct 19, 2021

Currently when an img element has a title, aria-label or aria-labelledby and a supported role i.e. button we report it as a violation, this appears to be a false positive as we do not report it as a violation when an alt tag is added.

<img role="button" alt="foo" /> - pass
<img role="button" aria-label="foo" /> - fail

<div id="bar">hello world</div>
<img role="button" aria-labelledby="bar" /> - fail

we have added a new matcher to match an element that has a non-empty accessible name. By doing so gives us the ability to add a matches property on a new variant noAlt that will check if the img element text is accessible (in this case, title, aria-label and, aria-labelledby) if an alt tag is not present.

W3C resources provided by the by the author in #3143:
https://www.w3.org/TR/html-aria/#el-img-no-alt
https://www.w3.org/TR/html-aam-1.0/#img-element-accessible-name-computation
https://www.w3.org/TR/html-aria/#el-img

Closes issue: #3143

@Zidious Zidious requested a review from a team as a code owner October 19, 2021 19:56
test/integration/rules/image-alt/image-alt.html Outdated Show resolved Hide resolved
lib/commons/aria/get-element-unallowed-roles.js Outdated Show resolved Hide resolved
lib/commons/aria/get-element-unallowed-roles.js Outdated Show resolved Hide resolved
@Zidious Zidious requested a review from straker October 28, 2021 21:17
@Zidious Zidious changed the title fix(aria-allowed-role): allow title, aria-label and aria-labelledby on img with supported role fix(aria-allowed-role): allow title, aria-label and aria-labelledby on a img element with a supported role Oct 28, 2021
lib/commons/matches/has-accessible-name.js Outdated Show resolved Hide resolved
lib/standards/html-elms.js Show resolved Hide resolved
test/commons/matches/has-accessible-name.js Show resolved Hide resolved
lib/standards/html-elms.js Outdated Show resolved Hide resolved
lib/commons/standards/get-element-spec.js Outdated Show resolved Hide resolved
@Zidious Zidious merged commit 006a681 into develop Nov 10, 2021
@Zidious Zidious deleted the fix-img/aria-allowed-role branch November 10, 2021 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants