Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.

Commit 9da0231

Browse files
author
Alice
committed
Merge pull request #246 from alice/href
Fix #245
2 parents 812ad9c + 5888ff9 commit 9da0231

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Bug fixes:
2+
3+
* `linkWithUnclearPurpose` should only look at links, not `<a>` without `href`. (#245)
4+
15
## 2.10.0-rc.0 - 2015-10-09
26

37
### New rules

src/audits/LinkWithUnclearPurpose.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ axs.AuditRules.addRule({
2929
* @return {boolean}
3030
*/
3131
relevantElementMatcher: function(element) {
32-
return axs.browserUtils.matchSelector(element, 'a') && !axs.utils.isElementOrAncestorHidden(element);
32+
return axs.browserUtils.matchSelector(element, 'a[href]') && !axs.utils.isElementOrAncestorHidden(element);
3333
},
3434
/**
3535
* @param {Element} anchor

test/audits/link-with-unclear-purpose.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,13 @@ test('a hidden link should not be run against the audit', function() {
132132
rule.run({scope: fixture}),
133133
{ result: axs.constants.AuditResult.NA });
134134
});
135+
136+
test('an anchor tag without href attribute is ignored', function() {
137+
var fixture = document.getElementById('qunit-fixture');
138+
fixture.appendChild(document.createElement('a'));
139+
140+
var rule = axs.AuditRules.getRule('linkWithUnclearPurpose');
141+
deepEqual(
142+
rule.run({scope: fixture}),
143+
{ result: axs.constants.AuditResult.NA });
144+
});

0 commit comments

Comments
 (0)