Skip to content

Commit

Permalink
fix(region): Allow skip menu buttons (#3277)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers authored Nov 18, 2021
1 parent d1cc205 commit 6b6f2e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/checks/navigation/region-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as dom from '../../commons/dom';
import * as aria from '../../commons/aria';
import { getRole } from '../../commons/aria';
import * as standards from '../../commons/standards';
import matches from '../../commons/matches';
import cache from '../../core/base/cache';
Expand All @@ -10,7 +10,7 @@ const implicitAriaLiveRoles = ['alert', 'log', 'status'];
// Check if the current element is a landmark
function isRegion(virtualNode, options) {
const node = virtualNode.actualNode;
const role = aria.getRole(virtualNode);
const role = getRole(virtualNode);
const ariaLive = (node.getAttribute('aria-live') || '').toLowerCase().trim();

// Ignore content inside of aria-live
Expand Down Expand Up @@ -41,6 +41,7 @@ function findRegionlessElms(virtualNode, options) {
const node = virtualNode.actualNode;
// End recursion if the element is a landmark, skiplink, or hidden content
if (
getRole(virtualNode) === 'button' ||
isRegion(virtualNode, options) ||
['iframe', 'frame'].includes(virtualNode.props.nodeName) ||
(dom.isSkipLink(virtualNode.actualNode) &&
Expand Down
1 change: 0 additions & 1 deletion test/aria-practices/apg.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('aria-practices', function () {
const disabledRules = {
'*': [
'color-contrast',
'region', // dequelabs/axe-core#3260
'heading-order', // w3c/aria-practices#2119
'list', // w3c/aria-practices#2118
'scrollable-region-focusable', // w3c/aria-practices#2114
Expand Down
9 changes: 9 additions & 0 deletions test/checks/navigation/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ describe('region', function() {
assert.isTrue(checkEvaluate.apply(checkContext, checkArgs));
});

it('should return true when there is a button', function() {
// Some pages have a skiplink menu, that opens through a button
// ARIA practices is an example of this.
var checkArgs = checkSetup(
'<button id="target">Skip menu</button><main><h1>Introduction</h1></main>'
);
assert.isTrue(checkEvaluate.apply(checkContext, checkArgs));
});

(shadowSupport.v1 ? it : xit)('should test Shadow tree content', function() {
var div = document.createElement('div');
var shadow = div.attachShadow({ mode: 'open' });
Expand Down

0 comments on commit 6b6f2e3

Please sign in to comment.