Skip to content

Commit

Permalink
fix(link-name): fix regression where link was not named from title at…
Browse files Browse the repository at this point in the history
…tribute (#2492)
  • Loading branch information
straker committed Sep 8, 2020
1 parent e2bbcfb commit b86c73b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/rules/link-name.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"aria-label",
"aria-labelledby",
"role-presentation",
"role-none"
"role-none",
"non-empty-title"
],
"none": ["focusable-no-name"]
}
3 changes: 3 additions & 0 deletions test/integration/rules/link-name/link-name.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@
aria-labelledby="nonexistent"
></span>

<a href="#" id="pass8" title="title text"></a>
<span role="link" href="#" tabindex="0" id="pass9" title="title text"></span>

<a href="#" role="button">Does not apply</a>
10 changes: 9 additions & 1 deletion test/integration/rules/link-name/link-name.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,13 @@
["#violation5"],
["#violation6"]
],
"passes": [["#pass1"], ["#pass3"], ["#pass4"], ["#pass6"], ["#pass7"]]
"passes": [
["#pass1"],
["#pass3"],
["#pass4"],
["#pass6"],
["#pass7"],
["#pass8"],
["#pass9"]
]
}
34 changes: 34 additions & 0 deletions test/integration/virtual-rules/link-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ describe('link-name', function() {
assert.lengthOf(results.incomplete, 0);
});

it('should pass for title', function() {
var node = new axe.SerialVirtualNode({
nodeName: 'a',
attributes: {
href: '/foo.html',
title: 'foobar'
}
});
node.children = [];

var results = axe.runVirtualRule('link-name', node);

assert.lengthOf(results.passes, 1);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});

it('should incomplete when aria-label and children are missing', function() {
var node = new axe.SerialVirtualNode({
nodeName: 'a',
Expand Down Expand Up @@ -169,4 +186,21 @@ describe('link-name', function() {
assert.lengthOf(results.violations, 1);
assert.lengthOf(results.incomplete, 0);
});

it('should fail when title is empty', function() {
var node = new axe.SerialVirtualNode({
nodeName: 'a',
attributes: {
href: '/foo.html',
title: ''
}
});
node.children = [];

var results = axe.runVirtualRule('link-name', node);

assert.lengthOf(results.passes, 0);
assert.lengthOf(results.violations, 1);
assert.lengthOf(results.incomplete, 0);
});
});

0 comments on commit b86c73b

Please sign in to comment.