Skip to content

No implicit role for <img> with alt="" #504

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

Merged
merged 2 commits into from
Dec 2, 2018
Merged

Conversation

othree
Copy link
Contributor

@othree othree commented Nov 23, 2018

Hi, I found the implicit role of <img> with alt="" is incorrect.
The document from W3C says it should have the corresponding role.

Ref: https://www.w3.org/TR/html-aria/#docconformance

@othree
Copy link
Contributor Author

othree commented Nov 23, 2018

I didn't update the test because I am not sure how to test role=''

@ljharb
Copy link
Member

ljharb commented Nov 23, 2018

The linked document says “no corresponding role” should NOT be used, and that the explicit options are “none” or “presentation”. What are we reading differently?

@ljharb ljharb requested a review from jessebeach November 23, 2018 15:26
@jessebeach
Copy link
Collaborator

The presentation role "MAY be used". Returning it explicitly in this case does feel a little ambiguous, yes. @othree have you observed aberrant behavior in the plugin because it returns a role of presentation for <img alt="" />?

I'd like to see the failing tests fixed so we better understand how this change ripples through the plugin. It might make sense to make it, but I'm not sure yet.

Copy link
Collaborator

@jessebeach jessebeach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments added above. Please fix the failing tests and then we'll decide if we should proceed with the change.

@othree
Copy link
Contributor Author

othree commented Nov 24, 2018

This is what I got yesterday.

screen shot on 2018-11-23 at 18_21_56

Trying to fill the test code.

@jessebeach
Copy link
Collaborator

@othree I see. Yes, that's not technically correct. I agree with the change.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.442% when pulling 477966f on othree:master into df9ce85 on evcohen:master.

@othree
Copy link
Contributor Author

othree commented Nov 26, 2018

I updated the test. And found if no 'role' provided. The aria attribute check will always pass.
So I update the invalid case to alt='foobar' instead of alt=''.

@@ -141,23 +141,8 @@ ruleTester.run('role-supports-aria-props', rule, {
// this will have global
{ code: '<link aria-checked />' },

// IMG TESTS - implicit role is `presentation`
{ code: '<img alt="" aria-atomic />' },
{ code: '<img alt="" aria-busy />' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove all these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the implicit role is not presentation.
The only way to change the role to presentation is by assigning it in the attribute.
But I didn't see any test case in this file have an assigned role.
All cases are using other ways to switch role, e.g. change value of type

@jessebeach
Copy link
Collaborator

@othree this is great, thank you for the test fixes. I appreciate the punctilious attention to spec detail :)

@jessebeach jessebeach merged commit 878ad19 into jsx-eslint:master Dec 2, 2018
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.

4 participants