diff --git a/lib/checks/label/title-only.js b/lib/checks/label/title-only.js index 64251d46fd..8d92a917d0 100644 --- a/lib/checks/label/title-only.js +++ b/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')); \ No newline at end of file diff --git a/test/checks/label/title-only.js b/test/checks/label/title-only.js index 7918883d4f..c934be7d15 100644 --- a/test/checks/label/title-only.js +++ b/test/checks/label/title-only.js @@ -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 () { @@ -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 () { @@ -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))); }); }); \ No newline at end of file