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

anchor-ambiguous-text: implements check for alt tags on <img /> elements #880

Merged
merged 1 commit into from
Aug 8, 2022
Merged

anchor-ambiguous-text: implements check for alt tags on <img /> elements #880

merged 1 commit into from
Aug 8, 2022

Conversation

mattxwang
Copy link
Contributor

This is a (small) PR that extends getAccessibleChildText to return the alt value of an <img /> (or bound) component instead of traversing its children. As a result, this lets the utility and anchor-ambiguous-text handle anchors that have images as children.

I add a few test cases and update the docs.

Part of (but does not close) #879.

@mattxwang mattxwang marked this pull request as ready for review July 27, 2022 22:49
@mattxwang mattxwang changed the title Implements check for alt tags on <img /> elements anchor-ambiguous-text: implements check for alt tags on <img /> elements Jul 27, 2022
@codecov
Copy link

codecov bot commented Jul 27, 2022

Codecov Report

Merging #880 (bb84abc) into main (c9687cc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #880   +/-   ##
=======================================
  Coverage   99.29%   99.29%           
=======================================
  Files         101      101           
  Lines        1553     1555    +2     
  Branches      510      511    +1     
=======================================
+ Hits         1542     1544    +2     
  Misses         11       11           
Impacted Files Coverage Δ
src/util/getAccessibleChildText.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Looks good. I'm a bit nervous this will break someone, and it would then need to be reverted and put behind an option, but we can give it a shot.

@mattxwang
Copy link
Contributor Author

I'm a bit nervous this will break someone, and it would then need to be reverted and put behind an option, but we can give it a shot.

anchor-ambiguous-text wasn't released yet, right? In that case, this would be the "default" behaviour. I also (personally) don't anticipate many use-cases where people have a good reason to have <img alt="click here" /> or something of the sort.

@ljharb
Copy link
Member

ljharb commented Aug 8, 2022

aha, good point :-) yay!

@ljharb ljharb merged commit bb84abc into jsx-eslint:main Aug 8, 2022
@mattxwang mattxwang deleted the improve-get-accessible-child branch August 8, 2022 21:28
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.

None yet

2 participants