-
Notifications
You must be signed in to change notification settings - Fork 470
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
Images with alt attributes cannot be grabbed ByRole #1235
Comments
Hi @brtrick, thanks for the detailed report :) |
Thanks. I finished the pr, but the codebase had 15 failing tests before I did anything (including a couple related to other issues in role-helpers.js), and now it doesn't want to let me commit because of the failed tests. Should I bypass verification and submit the pr anyway? Not sure how best to proceed... |
Hmm, the codebase shouldn't have failing tests, as you can see in the commits, the latest commits passed ci. |
Using Node 16.17 locally, but I get the same failures in all ci Node versions that I got locally. Tried cloning the repo directly for a fresh install; gives me the same 15 failures out of the box. |
Confirmed. I was using the new aria-query 5.2.1 that was released yesterday. When I reverted to 5.1.3, everything passed. |
Sleuthing through the aria-query changes, although the suggested change works around the issue it looks like there are potentially wider considerations may be needed. In A11yance/aria-query#447 it appears all Consequently the check for A naive search suggests there are potentially 9 scenarios where this constraint is no longer present in the latest version(s) of
|
@testing-library/dom
version: 9.3.0The Issue
If an
img
tag has analt
attribute, its role shows up aspresentation
instead of asimg
. So, e.g., this test:produces this result:
ARIA Background
According to the ARIA docs an
img
should only default to the role ofpresentation
if it has analt
attribute equal to "":Source of the Problem and Proposed Solution
The problem arises when the selector is being made in
role-helpers.js
:dom-testing-library/src/role-helpers.js
Lines 80 to 94 in d09b3c2
Because a value of
""
resolves to false in line 87, the selector for a presentationimg
ends up returning[alt]
instead of[alt=""]
as its characteristic attribute, meaning that anyimg
with analt
attribute will be marked with apresentation
role. Simply adding an explicit check forvalue === ""
on line 87 fixes the issue. (The check could be made more specific if that is needed.)I will submit a PR with the proposed fix and updated tests.
The text was updated successfully, but these errors were encountered: