Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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