diff --git a/lib/rules/skip-link-matches.js b/lib/rules/skip-link-matches.js index c642f0d443..03d6c6dd9b 100644 --- a/lib/rules/skip-link-matches.js +++ b/lib/rules/skip-link-matches.js @@ -1 +1 @@ -return axe.commons.dom.isSkipLink(node); +return axe.commons.dom.isSkipLink(node) && axe.commons.dom.isOffscreen(node); diff --git a/test/integration/full/skip-link/skip-link-fail.html b/test/integration/full/skip-link/skip-link-fail.html index c05b8325ed..0fa3b24dfe 100644 --- a/test/integration/full/skip-link/skip-link-fail.html +++ b/test/integration/full/skip-link/skip-link-fail.html @@ -20,7 +20,9 @@ - bad link 1 + bad link 1
diff --git a/test/integration/full/skip-link/skip-link-pass.html b/test/integration/full/skip-link/skip-link-pass.html index 05a267f2dc..619f5b1a7a 100644 --- a/test/integration/full/skip-link/skip-link-pass.html +++ b/test/integration/full/skip-link/skip-link-pass.html @@ -11,6 +11,21 @@ + diff --git a/test/rule-matches/skip-link-matches.js b/test/rule-matches/skip-link-matches.js index 07bca56fa4..3259415e26 100644 --- a/test/rule-matches/skip-link-matches.js +++ b/test/rule-matches/skip-link-matches.js @@ -8,8 +8,9 @@ describe('skip-link-matches', function() { rule = axe._audit.rules.find(function(rule) { return rule.id === 'skip-link'; }); - link = document.createElement('a'); - fixture.innerHTML = '
'; + fixture.innerHTML = + 'Click me
'; + link = fixture.querySelector('#target'); axe._tree = axe.utils.getFlattenedTree(fixture); }); @@ -22,6 +23,12 @@ describe('skip-link-matches', function() { assert.isFunction(rule.matches); }); + it('returns false if the links is onscreen', function() { + link.removeAttribute('style'); + link.href = '#main'; + assert.isFalse(rule.matches(link)); + }); + it('returns false if the href attribute does not start with #', function() { link.href = 'foo#bar'; assert.isFalse(rule.matches(link));