Skip to content

Commit

Permalink
fix(aria-valid-attr-value): allow aria-owns to pass when element is n…
Browse files Browse the repository at this point in the history
…ot in the DOM (dequelabs#1526)

* fix(aria-valid-attr-value): allow aria-owns to pass when element is not in the DOM

* add missing test
  • Loading branch information
straker committed May 1, 2019
1 parent 6a1bcba commit f835ed8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/checks/aria/valid-attr-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
};

Expand Down
28 changes: 28 additions & 0 deletions test/checks/aria/valid-attr-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<button aria-owns="test" aria-expanded="false">Button</button>'
);
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(
'<button aria-owns="test" aria-expanded="true">Button</button>'
);
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('<button aria-owns="test">Button</button>');
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 =
Expand Down

0 comments on commit f835ed8

Please sign in to comment.