From f835ed8d8c7db511612f4bb5ded42fda41778de6 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 1 May 2019 08:19:42 -0600 Subject: [PATCH] fix(aria-valid-attr-value): allow aria-owns to pass when element is not in the DOM (#1526) * fix(aria-valid-attr-value): allow aria-owns to pass when element is not in the DOM * add missing test --- lib/checks/aria/valid-attr-value.js | 6 ++++++ test/checks/aria/valid-attr-value.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/checks/aria/valid-attr-value.js b/lib/checks/aria/valid-attr-value.js index e007aae363..05e0715c15 100644 --- a/lib/checks/aria/valid-attr-value.js +++ b/lib/checks/aria/valid-attr-value.js @@ -15,6 +15,12 @@ const preChecks = { node.getAttribute('aria-expanded') !== 'false' && node.getAttribute('aria-selected') !== 'false' ); + }, + // aria-owns should only check if element exists if the element + // doesn't have aria-expanded=false (combobox) + // @see https://github.com/dequelabs/axe-core/issues/1524 + 'aria-owns': function() { + return node.getAttribute('aria-expanded') !== 'false'; } }; diff --git a/test/checks/aria/valid-attr-value.js b/test/checks/aria/valid-attr-value.js index b7f4109335..d62a25695e 100644 --- a/test/checks/aria/valid-attr-value.js +++ b/test/checks/aria/valid-attr-value.js @@ -177,6 +177,34 @@ describe('aria-valid-attr-value', function() { ); }); + it('should pass on aria-owns and aria-expanded=false when the element is not in the DOM', function() { + fixtureSetup( + '' + ); + var passing1 = fixture.querySelector('button'); + assert.isTrue( + checks['aria-valid-attr-value'].evaluate.call(checkContext, passing1) + ); + }); + + it('should fail on aria-owns and aria-expanded=true when the element is not in the DOM', function() { + fixtureSetup( + '' + ); + var failing1 = fixture.querySelector('button'); + assert.isFalse( + checks['aria-valid-attr-value'].evaluate.call(checkContext, failing1) + ); + }); + + it('should fail on aria-owns when the element is not in the DOM', function() { + fixtureSetup(''); + var failing1 = fixture.querySelector('button'); + assert.isFalse( + checks['aria-valid-attr-value'].evaluate.call(checkContext, failing1) + ); + }); + describe('options', function() { it('should exclude supplied attributes', function() { fixture.innerHTML =