-
Notifications
You must be signed in to change notification settings - Fork 784
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
Conversation
|
||
if (label && !axe.commons.dom.isVisible(label)) { | ||
return true; | ||
if (isLabelVisible === false) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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));
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Updated.
Closes #1176
Reviewer checks
Required fields, to be filled out by PR reviewer(s)