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: consider element's accessible names when labels are hidden #1187

Merged
merged 5 commits into from
Oct 22, 2018

Conversation

stephenmathieson
Copy link
Member

@stephenmathieson stephenmathieson commented Oct 10, 2018

Closes #1176

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: Marcy Sutton


if (label && !axe.commons.dom.isVisible(label)) {
return true;
if (isLabelVisible === false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this now fails if there is no label. Should probably just put the if statement back to the way it was.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. Will update!

@@ -4,7 +4,9 @@ if (node.getAttribute('id')) {
const label = root.querySelector(`label[for="${id}"]`);

if (label && !axe.commons.dom.isVisible(label)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should change this so it does !axe.commons.dom.isVisible(label, true)).

Here's a test case for it:

it('should fail when the label has aria-hidden=true', function() {
	var html = '';
	html += '<div>';
	html += '  <label for="target" aria-hidden="true">';
	html += '    Hello world';
	html += '  </label>';
	html += '  <input id="target">';
	html += '</div>';
	var args = checkSetup(html, {}, '#target');
	assert.isTrue(check.evaluate.apply(check, args));
});

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call! Updated.

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

3 participants