Skip to content

Commit

Permalink
fix(invalidrole): allow upper and mixed case role names (#4358)
Browse files Browse the repository at this point in the history
Closes: #2695
  • Loading branch information
lsprr committed Apr 1, 2024
1 parent f89c13b commit 105016c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checks/aria/invalidrole-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { tokenList } from '../../core/utils';
function invalidroleEvaluate(node, options, virtualNode) {
const allRoles = tokenList(virtualNode.attr('role'));
const allInvalid = allRoles.every(
role => !isValidRole(role, { allowAbstract: true })
role => !isValidRole(role.toLowerCase(), { allowAbstract: true })
);

/**
Expand Down
29 changes: 29 additions & 0 deletions test/checks/shared/invalidrole.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,33 @@ describe('invalidrole', function () {
);
assert.deepEqual(checkContext._data, ['foo', 'bar']);
});

it('should return true if applied to an uppercase nonsensical role', function () {
var virtualNode = queryFixture(
'<div id="target" role="FOO">Contents</div>'
);
assert.isTrue(
checks.invalidrole.evaluate.call(
checkContext,
virtualNode.actualNode,
null,
virtualNode
)
);
assert.deepEqual(checkContext._data, ['FOO']);
});

it('should return false if applied to an uppercase valid role', function () {
var virtualNode = queryFixture(
'<div id="target" role="BUTTON">Contents</div>'
);
assert.isFalse(
checks.invalidrole.evaluate.call(
checkContext,
virtualNode.actualNode,
null,
virtualNode
)
);
});
});

0 comments on commit 105016c

Please sign in to comment.