From 5ac278fe164f9a115066f2d09ea008700b77fa33 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Mon, 5 Aug 2019 09:09:29 -0600 Subject: [PATCH] fix(aria-form-field-name-matches): don't test combobox elements when they have a child input (#1742) * fix(aria-form-field-name-matches): don't test combobox elements when they have a child input * typo --- lib/rules/aria-form-field-name-matches.js | 11 +++++++++++ test/rule-matches/aria-form-field-name-matches.js | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/rules/aria-form-field-name-matches.js b/lib/rules/aria-form-field-name-matches.js index 78e5e08e90..09779d3aec 100644 --- a/lib/rules/aria-form-field-name-matches.js +++ b/lib/rules/aria-form-field-name-matches.js @@ -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; diff --git a/test/rule-matches/aria-form-field-name-matches.js b/test/rule-matches/aria-form-field-name-matches.js index 0e87567de4..a69535b36f 100644 --- a/test/rule-matches/aria-form-field-name-matches.js +++ b/test/rule-matches/aria-form-field-name-matches.js @@ -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( + '
' + ); + var actual = rule.matches(vNode.actualNode, vNode); + assert.isFalse(actual); + }); });