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(region): allow content in roles with implicit aria-live #2002

Merged
merged 1 commit into from
Jan 29, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/checks/navigation/region.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { dom, aria } = axe.commons;
const landmarkRoles = aria.getRolesByType('landmark');
const implicitAriaLiveRoles = ['alert', 'log', 'status'];

// Create a list of nodeNames that have a landmark as an implicit role
const implicitLandmarks = landmarkRoles
Expand All @@ -13,7 +14,10 @@ function isRegion(virtualNode) {
const ariaLive = (node.getAttribute('aria-live') || '').toLowerCase().trim();

// Ignore content inside of aria-live
if (['assertive', 'polite'].includes(ariaLive)) {
if (
['assertive', 'polite'].includes(ariaLive) ||
implicitAriaLiveRoles.includes(explicitRole)
) {
return true;
}

Expand Down
21 changes: 21 additions & 0 deletions test/checks/navigation/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,27 @@ describe('region', function() {
assert.isTrue(checks.region.evaluate.apply(checkContext, checkArgs));
});

it('allows content in implicit aria-live role alert', function() {
var checkArgs = checkSetup(
'<div role="alert" id="target"><p>This is random content.</p></div>'
);
assert.isTrue(checks.region.evaluate.apply(checkContext, checkArgs));
});

it('allows content in implicit aria-live role log', function() {
var checkArgs = checkSetup(
'<div role="log" id="target"><p>This is random content.</p></div>'
);
assert.isTrue(checks.region.evaluate.apply(checkContext, checkArgs));
});

it('allows content in implicit aria-live role status', function() {
var checkArgs = checkSetup(
'<div role="status" id="target"><p>This is random content.</p></div>'
);
assert.isTrue(checks.region.evaluate.apply(checkContext, checkArgs));
});

it('treats role=dialog elements as regions', function() {
var checkArgs = checkSetup(
'<div role="dialog" id="target"><p>This is random content.</p></div>'
Expand Down