Skip to content

Commit

Permalink
fix(checks/aria/required-children): add exception for native input co…
Browse files Browse the repository at this point in the history
…mbobox missing textbox

Remove textbox from the list of missing roles when checking a combobox node that is a native input element

#160
  • Loading branch information
isner authored and marcysutton committed Aug 9, 2017
1 parent fcc6380 commit 81ee2e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/checks/aria/required-children.js
Expand Up @@ -46,6 +46,15 @@ function missingRequiredChildren(node, childRoles, all) {
}
}

// combobox > textbox exception:
// remove textbox from missing roles if node is a native input
if (node.tagName === 'INPUT' && node.type === 'text') {
var textboxIndex = missing.indexOf('textbox');
if (textboxIndex >= 0) {
missing.splice(textboxIndex, 1);
}
}

if (missing.length) { return missing; }
if (!all && childRoles.length) { return childRoles; }
return null;
Expand Down
6 changes: 6 additions & 0 deletions test/checks/aria/required-children.js
Expand Up @@ -97,6 +97,12 @@ describe('aria-required-children', function () {
assert.isTrue(checks['aria-required-children'].evaluate.apply(checkContext, params));
});

it('should pass a native input with role comboxbox when missing child is role textbox', function () {
fixture.innerHTML = '<input type="text" role="combobox" aria-owns="listbox" id="target"></div><p role="listbox" id="listbox">Nothing here.</p>';
var node = fixture.querySelector('#target');
assert.isTrue(checks['aria-required-children'].evaluate.call(checkContext, node));
});

it('should pass one indirectly aria-owned child when one required', function () {
var params = checkSetup('<div role="grid" id="target" aria-owns="r"></div><div id="r"><div role="row">Nothing here.</div></div>');
assert.isTrue(checks['aria-required-children'].evaluate.apply(checkContext, params));
Expand Down

0 comments on commit 81ee2e4

Please sign in to comment.