From f4d801194001e884b0067940d40b590dab944420 Mon Sep 17 00:00:00 2001 From: Marcy Sutton Date: Thu, 4 Jan 2018 16:34:38 -0800 Subject: [PATCH] feat: allow options in aria-allowed-attr --- lib/checks/aria/allowed-attr.js | 4 +++- test/checks/aria/allowed-attr.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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'])); + }); + }); });