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 skip menu buttons #3277

Merged
merged 1 commit into from
Nov 18, 2021
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
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