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 =