Skip to content

Commit

Permalink
fix: Allow checkbox and radio groups with hidden aria-labelledby targ…
Browse files Browse the repository at this point in the history
…ets #188
  • Loading branch information
WilcoFiers committed Jan 10, 2018
1 parent c705903 commit 6149bde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checks/forms/group-labelledby.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ return [].map.call(matchingNodes, function (m) {
});
}).filter(function (n) {
var labelNode = doc.getElementById(n);
return labelNode && axe.commons.text.accessibleText(labelNode);
return labelNode && axe.commons.text.accessibleText(labelNode, true);
}).length !== 0;
16 changes: 16 additions & 0 deletions test/checks/forms/group-labelledby.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ describe('group-labelledby', function () {
});
});

it('should return true if there are ungrouped ' + type + ' elements with the same hidden name and with shared labelledby' +
'pointing to a node with text content', function () {

fixtureSetup('<p id="shared" style="display:none">Label</p>' +
'<input type="' + type + '" id="target" aria-labelledby="shared one" name="uniqueyname">' +
'<input type="' + type + '" aria-labelledby="shared two" name="uniqueyname">' +
'<input type="' + type + '" aria-labelledby="shared three" name="uniqueyname">');

var node = fixture.querySelector('#target');
assert.isTrue(check.evaluate.call(checkContext, node));
assert.deepEqual(checkContext._data, {
name: 'uniqueyname',
type: type
});
});

it('should return true if there are ungrouped ' + type + ' elements with the same name and with shared labelledby ' +
'pointing to a node with text content - SPECIAL CHARACTERS', function () {

Expand Down

0 comments on commit 6149bde

Please sign in to comment.