Skip to content

Commit

Permalink
fix(aria-allowed-role): allow role combobox on input tel, search, url…
Browse files Browse the repository at this point in the history
…, and email (#1850)
  • Loading branch information
michael-siek committed Oct 22, 2019
1 parent 7ac2d38 commit ba75961
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/commons/aria/index.js
Expand Up @@ -442,7 +442,7 @@ lookupTable.role = {
{
nodeName: 'input',
properties: {
type: 'text'
type: ['text', 'search', 'tel', 'url', 'email']
}
}
]
Expand Down Expand Up @@ -2146,15 +2146,6 @@ lookupTable.elementsAllowedNoRole = [
]
}
},
{
nodeName: 'input',
attributes: {
list: isNull
},
properties: {
type: ['email', 'search', 'tel', 'url']
}
},
{
nodeName: 'link',
attributes: {
Expand Down Expand Up @@ -2342,6 +2333,11 @@ lookupTable.evaluateRoleForElement = {
return (
role === 'combobox' || role === 'searchbox' || role === 'spinbutton'
);
case 'tel':
case 'url':
case 'search':
case 'email':
return role === 'combobox';
default:
return false;
}
Expand Down
40 changes: 40 additions & 0 deletions test/checks/aria/aria-allowed-role.js
Expand Up @@ -164,6 +164,46 @@ describe('aria-allowed-role', function() {
);
});

it('returns true when INPUT type is tel with role combobox', function() {
var node = document.createElement('input');
node.setAttribute('type', 'tel');
node.setAttribute('role', 'combobox');
fixture.appendChild(node);
assert.isTrue(
checks['aria-allowed-role'].evaluate.call(checkContext, node)
);
});

it('returns true when INPUT type is url with role combobox', function() {
var node = document.createElement('input');
node.setAttribute('type', 'url');
node.setAttribute('role', 'combobox');
fixture.appendChild(node);
assert.isTrue(
checks['aria-allowed-role'].evaluate.call(checkContext, node)
);
});

it('returns true when INPUT type is search with role combobox', function() {
var node = document.createElement('input');
node.setAttribute('type', 'search');
node.setAttribute('role', 'combobox');
fixture.appendChild(node);
assert.isTrue(
checks['aria-allowed-role'].evaluate.call(checkContext, node)
);
});

it('returns true when INPUT type is email with role combobox', function() {
var node = document.createElement('input');
node.setAttribute('type', 'email');
node.setAttribute('role', 'combobox');
fixture.appendChild(node);
assert.isTrue(
checks['aria-allowed-role'].evaluate.call(checkContext, node)
);
});

it('returns true when INPUT type is text with role spinbutton', function() {
var node = document.createElement('input');
node.setAttribute('type', 'text');
Expand Down
36 changes: 36 additions & 0 deletions test/integration/rules/aria-allowed-role/aria-allowed-role.html
Expand Up @@ -62,6 +62,42 @@ <h1 id="pass-h1-role-doc-subtitle" role="doc-subtitle"></h1>
aria-expanded="true"
id="pass-input-text-role-combobox"
/>
<input
aria-autocomplete="list"
aria-label="some label"
autocomplete="off"
role="combobox"
type="search"
aria-expanded="true"
id="pass-input-search-role-combobox"
/>
<input
aria-autocomplete="list"
aria-label="some label"
autocomplete="off"
role="combobox"
type="tel"
aria-expanded="true"
id="pass-input-tel-role-combobox"
/>
<input
aria-autocomplete="list"
aria-label="some label"
autocomplete="off"
role="combobox"
type="url"
aria-expanded="true"
id="pass-input-url-role-combobox"
/>
<input
aria-autocomplete="list"
aria-label="some label"
autocomplete="off"
role="combobox"
type="email"
aria-expanded="true"
id="pass-input-email-role-combobox"
/>
<input
aria-autocomplete="list"
aria-label="some label"
Expand Down
Expand Up @@ -36,6 +36,10 @@
["#pass-input-multiple-valid-and-invalid-roles"],
["#pass-input-text-role-searchbox"],
["#pass-input-text-role-combobox"],
["#pass-input-search-role-combobox"],
["#pass-input-tel-role-combobox"],
["#pass-input-url-role-combobox"],
["#pass-input-email-role-combobox"],
["#pass-input-text-role-spinbutton"],
["#pass-input-image-valid-role"],
["#pass-input-checkbox-valid-role"],
Expand Down

0 comments on commit ba75961

Please sign in to comment.