Skip to content

Commit

Permalink
Ignore hidden links for LinkText plugin - fixes #101
Browse files Browse the repository at this point in the history
  • Loading branch information
jdan committed Oct 3, 2016
1 parent db8746c commit 30dc0fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/link-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class LinkTextPlugin extends Plugin {
return;
}

// Ignore hidden links
if (axs.utils.isElementOrAncestorHidden(el)) {
return;
}

// Extract the text alternatives for this element: including
// its text content, aria-label/labelledby, and alt text for
// images.
Expand Down
13 changes: 13 additions & 0 deletions test/link-text-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,17 @@ describe("Link text plugin", function() {
assert($("#empty-link-with-unclear-label").hasLabel());
assert($("#empty-link-with-unclear-labelledby").hasLabel());
});

it("should not fail on hidden links", function() {
document.body.innerHTML = `
<ul style="display:none;">
<li>
<a id="hidden-link" href="#">About</a>
</li>
</ul>
`;

plugin.run();
assert(!$("#hidden-link").hasLabel());
});
});

0 comments on commit 30dc0fd

Please sign in to comment.