From 6a2b17f1c7e966dc1108f523c741ed04a5055873 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 13 Dec 2017 10:56:52 +0100 Subject: [PATCH 1/2] fix(rules/region): Treat
as a landmark if it has an accessible name #640 --- lib/checks/navigation/region.js | 6 ++++-- lib/commons/aria/index.js | 4 ++-- package.json | 2 +- test/integration/full/region/region-fail.html | 3 +++ test/integration/full/region/region-pass.html | 10 ++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/checks/navigation/region.js b/lib/checks/navigation/region.js index a956251dd2..f40ff581fa 100644 --- a/lib/checks/navigation/region.js +++ b/lib/checks/navigation/region.js @@ -14,7 +14,7 @@ const landmarkRoles = aria.getRolesByType('landmark'); // Create a list of nodeNames that have a landmark as an implicit role const implicitLandmarks = landmarkRoles .reduce((arr, role) => arr.concat(aria.implicitNodes(role)), []) - .filter(r => r !== null).map(r => r.toUpperCase()); + .filter(r => r !== null); // Check if the current element is the skiplink function isSkipLink (node) { @@ -26,7 +26,9 @@ function isLandmark (node) { if (node.hasAttribute('role')) { return landmarkRoles.includes(node.getAttribute('role').toLowerCase()); } else { - return implicitLandmarks.includes(node.nodeName.toUpperCase()); + return implicitLandmarks.some((implicitSelector) => { + return axe.utils.matchesSelector(node, implicitSelector); + }); } } diff --git a/lib/commons/aria/index.js b/lib/commons/aria/index.js index ed88d832a4..d9ac6e25e0 100644 --- a/lib/commons/aria/index.js +++ b/lib/commons/aria/index.js @@ -640,14 +640,14 @@ lookupTables.role = { type: 'abstract' }, 'region': { - type: 'structure', + type: 'landmark', attributes: { allowed: ['aria-expanded'] }, owned: null, nameFrom: ['author'], context: null, - implicit: ['section'] + implicit: ['section[aria-label]', 'section[aria-labelledby]', 'section[title]'] }, 'roletype': { type: 'abstract' diff --git a/package.json b/package.json index 2f2110bdd0..0871a675f8 100644 --- a/package.json +++ b/package.json @@ -92,4 +92,4 @@ "standard-version": "^4.2.0" }, "dependencies": {} -} \ No newline at end of file +} diff --git a/test/integration/full/region/region-fail.html b/test/integration/full/region/region-fail.html index 2cd42497a5..c50528b65b 100644 --- a/test/integration/full/region/region-fail.html +++ b/test/integration/full/region/region-fail.html @@ -25,6 +25,9 @@

This is a header.

  • Home
  • Other
  • +
    +

    Content

    +
    diff --git a/test/integration/full/region/region-pass.html b/test/integration/full/region/region-pass.html index 5d812db301..fc320e6030 100644 --- a/test/integration/full/region/region-pass.html +++ b/test/integration/full/region/region-pass.html @@ -25,6 +25,16 @@

    This is a header.

  • Home
  • Other
  • +
    +

    Section heading

    +

    Content

    +
    +
    +

    Content

    +
    +
    +

    Content

    +
    From 7b301b60e06614532667624db6e8085102dee96f Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Fri, 15 Dec 2017 11:43:11 +0100 Subject: [PATCH 2/2] chore(checks/region): Add clarifying comment --- lib/checks/navigation/region.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/checks/navigation/region.js b/lib/checks/navigation/region.js index f40ff581fa..7bc43b0955 100644 --- a/lib/checks/navigation/region.js +++ b/lib/checks/navigation/region.js @@ -26,6 +26,7 @@ function isLandmark (node) { if (node.hasAttribute('role')) { return landmarkRoles.includes(node.getAttribute('role').toLowerCase()); } else { + // Check if the node matches any of the CSS selectors of implicit landmarks return implicitLandmarks.some((implicitSelector) => { return axe.utils.matchesSelector(node, implicitSelector); });