Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(link-name): fix regression where link was not named from title attribute #2492

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});