Skip to content

Commit

Permalink
feat: allow options in aria-allowed-attr
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcy Sutton committed Jan 5, 2018
1 parent 66646a8 commit f4d8011
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/checks/aria/allowed-attr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
options = Array.isArray(options) ? options : [];

var invalid = [];

var attr, attrName, allowed,
Expand All @@ -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 + '"');
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/checks/aria/allowed-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div role="separator" id="target" aria-valuenow="0" aria-valuemin="-2" aria-valuemax="4"></div>';
var target = fixture.children[0];
assert.isTrue(checks['aria-allowed-attr'].evaluate.call(checkContext, target, ['aria-valuenow', 'aria-valuemin', 'aria-valuemax']));
});
});
});

0 comments on commit f4d8011

Please sign in to comment.