diff --git a/lib/checks/aria/allowed-attr.js b/lib/checks/aria/allowed-attr.js index 3a9f614610..c33c38a8ea 100644 --- a/lib/checks/aria/allowed-attr.js +++ b/lib/checks/aria/allowed-attr.js @@ -1,3 +1,5 @@ +options = Array.isArray(options) ? options : []; + var invalid = []; var attr, attrName, allowed, @@ -12,7 +14,7 @@ if (role && allowed) { for (var i = 0, l = attrs.length; i < l; i++) { attr = attrs[i]; attrName = attr.name; - if (axe.commons.aria.validateAttr(attrName) && allowed.indexOf(attrName) === -1) { + if (options.indexOf(attrName) === -1 && axe.commons.aria.validateAttr(attrName) && allowed.indexOf(attrName) === -1) { invalid.push(attrName + '="' + attr.nodeValue + '"'); } } diff --git a/test/checks/aria/allowed-attr.js b/test/checks/aria/allowed-attr.js index 7ff80fd54e..4a2b722bff 100644 --- a/test/checks/aria/allowed-attr.js +++ b/test/checks/aria/allowed-attr.js @@ -119,4 +119,11 @@ describe('aria-allowed-attr', function () { assert.isNull(checkContext._data); }); + describe('options', function () { + it('should exclude provided attribute names', function () { + fixture.innerHTML = '
'; + var target = fixture.children[0]; + assert.isTrue(checks['aria-allowed-attr'].evaluate.call(checkContext, target, ['aria-valuenow', 'aria-valuemin', 'aria-valuemax'])); + }); + }); });