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

Don't require redundant role for <img alt="" /> in require-valid-alt-text rule #2954

Merged

Conversation

HeroicEric
Copy link
Contributor

@HeroicEric HeroicEric commented Aug 9, 2023

Closes #2951,
Closes #2190,
Closes #2579,
Closes #2828

This updates the require-valid-alt-text rule so that it does not require setting role="presentation" or role="none" for an <img alt="" />.

Context

After bumping aria-query in #2927, ember-template-lint began reporting an error for the following:

<img alt="" role="presentation" />

The error is from the no-redundant-role. I believe it is correct to report an error in this case because <img alt="" /> already implicitly has a role of presentation.

However, this new behavior was in direct conflict with part of the require-valid-alt-text rule that required setting role="presentation" or role="none" whenever an image has alt="". It is valid to set one of these roles but it should not be required. Removing this requirement allows these two rules (no-redundant-role and require-valid-alt-text) to continue to be used together.

Fixes ember-template-lint#2951

This updates the `require-valid-alt-text` rule so that it does not
*require* setting `role="presentation"` or `role="none"` for an `<img
alt="" />`.

Context

After bumping `aria-query` in ember-template-lint#2927,
`ember-template-lint` began reporting an error for the following:

```html
<img alt="" role="presentation" />
```

The error is from the `no-redundant-role`. I believe it is correct to
report an error in this case because `<img alt="" />` already implicitly
has a `role` of `presentation`.

However, this new behavior was in direct conflict with part of the
`require-valid-alt-text` rule that required setting
`role="presentation"` or `role="none"` whenever an image has `alt=""`.
@HeroicEric HeroicEric force-pushed the fix-dont-require-redundant-role branch from f269000 to e413335 Compare August 9, 2023 20:27
@HeroicEric
Copy link
Contributor Author

Just realized someone already started on this in #2828 🙃

I believe the fix in this branch to be more correct because #2828 (comment)

@bmish bmish requested a review from MelSumner August 11, 2023 09:58
@bmish bmish added the bug label Aug 11, 2023
@bmish bmish changed the title fix: Don't require redundant role for <img alt="" /> Don't require redundant role for <img alt="" /> in require-valid-alt-text rule Aug 11, 2023
@bmish
Copy link
Member

bmish commented Aug 11, 2023

Seems reasonable. Should we proceed with this PR? @yannbertrand @jaswilli @MelSumner

Copy link
Member

@bmish bmish left a comment

Choose a reason for hiding this comment

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

Thanks!

@bmish bmish merged commit 190be4c into ember-template-lint:master Aug 12, 2023
11 checks passed
@HeroicEric HeroicEric deleted the fix-dont-require-redundant-role branch August 14, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants