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(required-children): add combobox > listbox exception #559

Merged
merged 3 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checks/aria/required-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function missingRequiredChildren(node, childRoles, all, role) {

// remove 'textbox' from missing roles if combobox is a native input
var textboxIndex = missing.indexOf('textbox');
if (textboxIndex >= 0 && node.tagName === 'INPUT' && node.type === 'text') {
if (textboxIndex >= 0 && node.tagName === 'INPUT' && ['text', 'search'].indexOf(node.type) >= 0) {
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 there are probably other types that make sense too.

Copy link
Contributor Author

@isner isner Oct 9, 2017

Choose a reason for hiding this comment

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

Good point. Which other types are you thinking of? To me, the only other types that seem reasonable to use as the basis of a combobox are "email" and "url". Beyond that, "tel" might be worth supporting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added "email", "url", and "tel" to the excepted input types.

missing.splice(textboxIndex, 1);
}

Expand Down
9 changes: 7 additions & 2 deletions test/checks/aria/required-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ 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 () {
var params = checkSetup('<input type="text" role="combobox" aria-owns="listbox" id="target"></div><p role="listbox" id="listbox">Nothing here.</p>');
it('should pass a native "text" type input with role comboxbox when missing child is role textbox', function () {
var params = checkSetup('<input type="text" role="combobox" aria-owns="listbox" id="target"><p role="listbox" id="listbox">Nothing here.</p>');
assert.isTrue(checks['aria-required-children'].evaluate.apply(checkContext, params));
});

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

Expand Down