Skip to content

Commit

Permalink
fix: use virtualNode in title-only check
Browse files Browse the repository at this point in the history
Closes #388
  • Loading branch information
Marcy Sutton committed Jun 30, 2017
1 parent dbbc544 commit 5fb06e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/checks/label/title-only.js
@@ -1,2 +1,2 @@
var labelText = axe.commons.text.label(node);
var labelText = axe.commons.text.label(virtualNode);
return !labelText && !!(node.getAttribute('title') || node.getAttribute('aria-describedby'));
13 changes: 9 additions & 4 deletions test/checks/label/title-only.js
Expand Up @@ -5,6 +5,7 @@ describe('title-only', function () {

afterEach(function () {
fixture.innerHTML = '';
axe._tree = undefined;
});

it('should return true if an element only has a title', function () {
Expand All @@ -14,9 +15,11 @@ describe('title-only', function () {

fixture.appendChild(node);

assert.isTrue(checks['title-only'].evaluate(node));
var tree = axe._tree = axe.utils.getFlattenedTree(fixture);

assert.isTrue(checks['title-only'].evaluate(node, undefined, axe.utils.getNodeFromTree(tree[0], node)));
node.setAttribute('aria-label', 'woop');
assert.isFalse(checks['title-only'].evaluate(node));
assert.isFalse(checks['title-only'].evaluate(node, undefined, axe.utils.getNodeFromTree(tree[0], node)));
});

it('should return true if an element only has aria-describedby', function () {
Expand All @@ -30,9 +33,11 @@ describe('title-only', function () {
fixture.appendChild(node);
fixture.appendChild(dby);

assert.isTrue(checks['title-only'].evaluate(node));
var tree = axe._tree = axe.utils.getFlattenedTree(fixture);

assert.isTrue(checks['title-only'].evaluate(node, undefined, axe.utils.getNodeFromTree(tree[0], node)));
node.setAttribute('aria-label', 'woop');
assert.isFalse(checks['title-only'].evaluate(node));
assert.isFalse(checks['title-only'].evaluate(node, undefined, axe.utils.getNodeFromTree(tree[0], node)));
});

});

0 comments on commit 5fb06e3

Please sign in to comment.