Skip to content

Commit

Permalink
fix(region): allow content in roles with implicit aria-live (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed Jan 29, 2020
1 parent b49bd95 commit a8d829e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/checks/navigation/region.js
@@ -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
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

0 comments on commit a8d829e

Please sign in to comment.