From 3d5e8f3c672bd8477fc1d2f0f526a1c3b51220e8 Mon Sep 17 00:00:00 2001 From: Michael Youngstrom Date: Tue, 26 Feb 2019 13:12:15 -0500 Subject: [PATCH] Bump axe-core version --- lib/custom_a11y_rules.js | 11 ++++++++--- package.json | 4 ++-- test/fixtures/skip-link-fail.html | 3 +-- test/spec/rules_spec.js | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/custom_a11y_rules.js b/lib/custom_a11y_rules.js index 69b8579..3e6e4c9 100644 --- a/lib/custom_a11y_rules.js +++ b/lib/custom_a11y_rules.js @@ -55,9 +55,9 @@ var customRules = { 'any': ['skip-link'], 'none': [], 'metadata': { - 'description': 'Ensures the first link on the page is a skip link', - 'help': 'The page should have a skip link as its first link', - 'helpUrl': 'https://dequeuniversity.com/rules/axe/1.1/skip-link' + 'description': 'Ensures that all skip links have a valid target', + 'help': 'All skip links should have a valid target, allowing users to skip the navigation', + 'helpUrl': 'https://dequeuniversity.com/rules/axe/3.2/skip-link' } }, { @@ -117,6 +117,7 @@ var customRules = { } }, evaluate: function(node, options) { + axe._tree = axe.utils.getFlattenedTree(node); return axe.commons.aria.label(node) !== null; } }, @@ -132,6 +133,7 @@ var customRules = { } }, evaluate: function(node, options) { + axe._tree = axe.utils.getFlattenedTree(node); var label = axe.commons.aria.label(node) || '', words = label.toLowerCase().split(' '); return words.indexOf('nav') < 0 && words.indexOf('navigation') < 0; @@ -170,6 +172,9 @@ var customRules = { rel = node.getAttribute('rel') || ''; if (href.startsWith('#') && href.length > 1 && rel !== 'leanModal') { linkTarget = document.querySelector(href); + if (!linkTarget) { + return false; + } return axe.commons.dom.isFocusable(linkTarget); } else { return true; diff --git a/package.json b/package.json index c23a30d..3436b34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edx-custom-a11y-rules", - "version": "1.0.5", + "version": "1.0.6", "description": "Custom rules for accessibility testing with aXe Core", "main": "", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/edx/edx-custom-a11y-rules#readme", "devDependencies": { - "axe-core": "~1.1.0", + "axe-core": "~3.2.2", "jasmine-core": "^2.3.4", "jshint": "^2.8.0", "karma": "^0.13.10", diff --git a/test/fixtures/skip-link-fail.html b/test/fixtures/skip-link-fail.html index 4eb7907..deed354 100644 --- a/test/fixtures/skip-link-fail.html +++ b/test/fixtures/skip-link-fail.html @@ -1,3 +1,2 @@ -{# This will fail despite the href being OK because "main-content" div isn't focusable. #} -Skip to main content +Skip to main content
Main content
diff --git a/test/spec/rules_spec.js b/test/spec/rules_spec.js index 0b254cc..51378f6 100644 --- a/test/spec/rules_spec.js +++ b/test/spec/rules_spec.js @@ -32,7 +32,7 @@ describe('Rules Spec', function () { axe.configure(rules); jasmine.getFixtures().fixturesPath = '/base/'; loadFixtures('test/fixtures/' + fixture); - axe.a11yCheck(document, {}, function (r) { results = r; done(); }); + axe.run(document, function (err, result) { results = result; done(); }); }); it(fixture + ', should ' + expectedResult, function () {