diff --git a/lib/checks/aria/aria-valid-attr-value-evaluate.js b/lib/checks/aria/aria-valid-attr-value-evaluate.js index a5a04deed3..edd5d56796 100644 --- a/lib/checks/aria/aria-valid-attr-value-evaluate.js +++ b/lib/checks/aria/aria-valid-attr-value-evaluate.js @@ -74,6 +74,17 @@ function ariaValidAttrValueEvaluate(node, options) { } return; + }, + // aria-labelledby should not mark missing element as violation but + // instead as needs review + // @see https://github.com/dequelabs/axe-core/issues/2621 + 'aria-labelledby': () => { + if (!validateAttrValue(node, 'aria-labelledby')) { + needsReview = `aria-labelledby="${node.getAttribute( + 'aria-labelledby' + )}"`; + messageKey = 'noId'; + } } }; diff --git a/test/checks/aria/valid-attr-value.js b/test/checks/aria/valid-attr-value.js index 8c0108feff..8e9dfbdce5 100644 --- a/test/checks/aria/valid-attr-value.js +++ b/test/checks/aria/valid-attr-value.js @@ -232,6 +232,16 @@ describe('aria-valid-attr-value', function() { ); }); + it('should return undefined on aria-labelledby when the element is not in the DOM', function() { + fixtureSetup(''); + var undefined1 = fixture.querySelector('button'); + assert.isUndefined( + axe.testUtils + .getCheckEvaluate('aria-valid-attr-value') + .call(checkContext, undefined1) + ); + }); + it('should return undefined on aria-current with invalid value', function() { fixtureSetup(''); var undefined1 = fixture.querySelector('button'); diff --git a/test/integration/rules/aria-valid-attr-value/aria-valid-attr-value.html b/test/integration/rules/aria-valid-attr-value/aria-valid-attr-value.html index aaf14c27ba..7d1ed37c33 100644 --- a/test/integration/rules/aria-valid-attr-value/aria-valid-attr-value.html +++ b/test/integration/rules/aria-valid-attr-value/aria-valid-attr-value.html @@ -19,7 +19,6 @@