From b86c73b7dc61c2609afa6f384502f3c91f9a7f10 Mon Sep 17 00:00:00 2001
From: Steven Lambert <2433219+straker@users.noreply.github.com>
Date: Thu, 27 Aug 2020 08:35:39 -0600
Subject: [PATCH] fix(link-name): fix regression where link was not named from
title attribute (#2492)
---
lib/rules/link-name.json | 3 +-
.../rules/link-name/link-name.html | 3 ++
.../rules/link-name/link-name.json | 10 +++++-
test/integration/virtual-rules/link-name.js | 34 +++++++++++++++++++
4 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/lib/rules/link-name.json b/lib/rules/link-name.json
index 5b2edf2a44..99941d1a47 100644
--- a/lib/rules/link-name.json
+++ b/lib/rules/link-name.json
@@ -19,7 +19,8 @@
"aria-label",
"aria-labelledby",
"role-presentation",
- "role-none"
+ "role-none",
+ "non-empty-title"
],
"none": ["focusable-no-name"]
}
diff --git a/test/integration/rules/link-name/link-name.html b/test/integration/rules/link-name/link-name.html
index 458afcf8bf..101f8379db 100644
--- a/test/integration/rules/link-name/link-name.html
+++ b/test/integration/rules/link-name/link-name.html
@@ -36,4 +36,7 @@
aria-labelledby="nonexistent"
>
+
+
+
Does not apply
diff --git a/test/integration/rules/link-name/link-name.json b/test/integration/rules/link-name/link-name.json
index 347cc0e6b3..a6085c0443 100644
--- a/test/integration/rules/link-name/link-name.json
+++ b/test/integration/rules/link-name/link-name.json
@@ -9,5 +9,13 @@
["#violation5"],
["#violation6"]
],
- "passes": [["#pass1"], ["#pass3"], ["#pass4"], ["#pass6"], ["#pass7"]]
+ "passes": [
+ ["#pass1"],
+ ["#pass3"],
+ ["#pass4"],
+ ["#pass6"],
+ ["#pass7"],
+ ["#pass8"],
+ ["#pass9"]
+ ]
}
diff --git a/test/integration/virtual-rules/link-name.js b/test/integration/virtual-rules/link-name.js
index 74db1542ee..3da3fdb20d 100644
--- a/test/integration/virtual-rules/link-name.js
+++ b/test/integration/virtual-rules/link-name.js
@@ -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',
@@ -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);
+ });
});