-
Notifications
You must be signed in to change notification settings - Fork 235
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
Remove role
requirement for img
tags in require-valid-alt-text
#2828
Remove role
requirement for img
tags in require-valid-alt-text
#2828
Conversation
63aad8a
to
24c130e
Compare
img
tags should not have role
attributerole
requirement for img
tags in require-valid-alt-text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this rule optional instead of removing it; it's weird but also the only way we can currently identify developer intent. It's also on the topic list for the next ARIA face to face.
Thanks for the review. What do you mean by making the rule optional? Should I remove these lines?
Interesting! Is there a planning of these events we can find somewhere? |
I've added a commit to accept |
3ee578c
to
61e2518
Compare
61e2518
to
1418b8f
Compare
…er-template-lint#2852) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…e-lint#2851) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…nt#2850) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
I think the intended changes here have become more urgent with the recent aria-query updates. Now both versions of an empty alt with presentation role: $ echo '<img src="src" alt="" role="presentation">' | npx ember-template-lint --
undefined
1:0 error Use of redundant or invalid role: presentation on <img> detected. no-redundant-role empty alt without role: $ echo '<img src="src" alt="">' | npx ember-template-lint --
undefined
1:0 error If the `alt` attribute is present and the value is an empty string, `role="presentation"` or `role="none"` must be present require-valid-alt-text |
'<img alt="" role="none" src="zoey.jpg">', | ||
'<img alt="" role="presentation" src="zoey.jpg">', | ||
'<img alt="a stylized graphic of a female hamster" src="zoey.jpg">', | ||
'<img alt="a stylized graphic of a female hamster" role="presentation" src="zoey.jpg">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role="presentation"
and role="none"
are not valid when alt
is a non-empty string
// if the role value is a mustache statement we can not validate it | ||
if (hasAltAttribute && hasRole && !roleValue.type) { | ||
if ( | ||
['none', 'presentation'].includes(roleValue.trim().toLowerCase()) && | ||
altValue !== '' | ||
) { | ||
this.logNode({ | ||
message: | ||
'The `alt` attribute should be empty if `<img>` has `role` of `none` or `presentation`', | ||
node, | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be removed. It is not valid to have a non-empty alt attribute if role="presentation"
or role="none"
.
Removing this is not necessary to remove the requirement of setting role="presentation"
or role="none"
and doing so allows invalid markup like <img alt="non-empty-text" role="presentation" />
I'm closing this in favor of #2954 |
Affects
require-valid-alt-text
.role
should never be needed when using animg
tag according to the W3C Nu Validator.Closes #2190
Closes #2579.