Skip to content

Commit

Permalink
fix(region-rule): allow live regions with explicit roles (#1999)
Browse files Browse the repository at this point in the history
  • Loading branch information
madalynrose authored and WilcoFiers committed Jan 27, 2020
1 parent 39b8eae commit b49bd95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/checks/navigation/region.js
Expand Up @@ -12,14 +12,15 @@ function isRegion(virtualNode) {
const explicitRole = axe.commons.aria.getRole(node, { noImplicit: true });
const ariaLive = (node.getAttribute('aria-live') || '').toLowerCase().trim();

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

if (explicitRole) {
return explicitRole === 'dialog' || landmarkRoles.includes(explicitRole);
}

// Check if the node matches any of the CSS selectors of implicit landmarks
return implicitLandmarks.some(implicitSelector => {
let matches = axe.utils.matchesSelector(node, implicitSelector);
Expand Down
14 changes: 14 additions & 0 deletions test/checks/navigation/region.js
Expand Up @@ -241,6 +241,20 @@ describe('region', function() {
assert.isFalse(checks.region.evaluate.apply(checkContext, checkArgs));
});

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

it('allows content in aria-live=polite with explicit role set', function() {
var checkArgs = checkSetup(
'<div aria-live="polite" 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 b49bd95

Please sign in to comment.