Skip to content

Commit

Permalink
fix(aria-form-field-name-matches): don't test combobox elements when …
Browse files Browse the repository at this point in the history
…they have a child input (#1742)

* fix(aria-form-field-name-matches): don't test combobox elements when they have a child input

* typo
  • Loading branch information
straker committed Aug 12, 2019
1 parent 6909604 commit 5ac278f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/rules/aria-form-field-name-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@ if (nodeName === 'BUTTON' || role === 'button') {
return false;
}

/**
* Ignore combobox elements if they have a child input
* (ARIA 1.1 pattern)
*/
if (
role === 'combobox' &&
axe.utils.querySelectorAll(virtualNode, 'input:not([type="hidden"])').length
) {
return false;
}

return true;
8 changes: 8 additions & 0 deletions test/rule-matches/aria-form-field-name-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ describe('aria-form-field-name-matches', function() {
assert.isFalse(actual);
});
});

it('returns false when role=`combobox` has a child input', function() {
var vNode = queryFixture(
'<div id="target" role="combobox"><input type="text"/></div>'
);
var actual = rule.matches(vNode.actualNode, vNode);
assert.isFalse(actual);
});
});

0 comments on commit 5ac278f

Please sign in to comment.