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

fix(image-redundant-alt): prevent redundant issues of image tree #1616

Merged
merged 3 commits into from
Jun 7, 2019

Conversation

straker
Copy link
Contributor

@straker straker commented Jun 5, 2019

The image-redundant-alt rule applied to more than just buttons and links (as the help text stated). It also was being applied to p, li, td, and th elements. This caused a single image to be reported multiple times if it's parent tree consisted of each of those elements:

<td>
  <p>
    <button>
      <img alt="Alt text">
      Alt text
    </button>
  </p>
</td>

This changes the rule to focus only on img elements and look up the tree for the button, [role=button], a[href], p, li, td, and th elements and check the text against the image alt. This way only the image node will throw the error and not each parent node.

Linked issue: #1416

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: @WilcoFiers

@straker straker requested a review from a team as a code owner June 5, 2019 22:31
Copy link
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

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

Very minor point.

lib/checks/label/duplicate-img-label.js Outdated Show resolved Hide resolved
lib/checks/label/duplicate-img-label.js Outdated Show resolved Hide resolved
@WilcoFiers WilcoFiers added this to the Axe-core 3.3 milestone Jun 6, 2019
@straker straker removed this from the Axe-core 3.3 milestone Jun 6, 2019
WilcoFiers
WilcoFiers previously approved these changes Jun 7, 2019
@straker straker merged commit af81897 into develop Jun 7, 2019
@straker straker deleted the imageRedundantAlt branch June 7, 2019 14:55
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.

2 participants