Skip to content

Commit 2c47c8d

Browse files
author
Todd Kloots
committed
[fixed] issue where elements with the presentation role required a label. resolves #50
1 parent 1239d62 commit 2c47c8d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

lib/__tests__/index-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ describe('labels', () => {
194194
});
195195
});
196196

197+
it('does not warn when the ARIA role is presentation', () => {
198+
doNotExpectWarning(assertions.render.NO_LABEL.msg, () => {
199+
<span role="presentation" />;
200+
});
201+
});
202+
197203
it('does not warn if the element is not interactive', () => {
198204
doNotExpectWarning(assertions.render.NO_LABEL.msg, () => {
199205
<div />;

lib/assertions.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,16 @@ exports.render = {
180180
NO_LABEL: {
181181
msg: 'You have an unlabled element or control. Add `aria-label` or `aria-labelled-by` attribute, or put some text in the element.',
182182
test (tagName, props, children, failureCB) {
183-
if (!(isInteractive(tagName, props) || props.role))
183+
var labelRequired = (
184+
isInteractive(tagName, props) ||
185+
props.role && props.role != 'presentation'
186+
);
187+
188+
if (!labelRequired)
184189
return;
185190

186191
var failed = !(
187-
(isInteractive(tagName, props) || props.role) &&
192+
labelRequired &&
188193
(
189194
props['aria-label'] ||
190195
props['aria-labelled-by'] ||

0 commit comments

Comments
 (0)