Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(invalidrole): allow upper and mixed case role names #4358

Merged
merged 7 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 15 additions & 0 deletions test/checks/shared/invalidrole.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,19 @@ 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>'
lsprr marked this conversation as resolved.
Show resolved Hide resolved
);
assert.isTrue(
checks.invalidrole.evaluate.call(
checkContext,
virtualNode.actualNode,
null,
virtualNode
)
);
assert.deepEqual(checkContext._data, ['FOO']);
});
});