Skip to content

Commit 878ad19

Browse files
authored
Merge pull request #504 from othree/master
No implicit role for `<img>` with `alt=""`
2 parents df9ce85 + 477966f commit 878ad19

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

__tests__/src/rules/role-supports-aria-props-test.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,8 @@ ruleTester.run('role-supports-aria-props', rule, {
141141
// this will have global
142142
{ code: '<link aria-checked />' },
143143

144-
// IMG TESTS - implicit role is `presentation`
145-
{ code: '<img alt="" aria-atomic />' },
146-
{ code: '<img alt="" aria-busy />' },
147-
{ code: '<img alt="" aria-controls />' },
148-
{ code: '<img alt="" aria-describedby />' },
149-
{ code: '<img alt="" aria-disabled />' },
150-
{ code: '<img alt="" aria-dropeffect />' },
151-
{ code: '<img alt="" aria-flowto />' },
152-
{ code: '<img alt="" aria-grabbed />' },
153-
{ code: '<img alt="" aria-haspopup />' },
154-
{ code: '<img alt="" aria-hidden />' },
155-
{ code: '<img alt="" aria-invalid />' },
156-
{ code: '<img alt="" aria-label />' },
157-
{ code: '<img alt="" aria-labelledby />' },
158-
{ code: '<img alt="" aria-live />' },
159-
{ code: '<img alt="" aria-owns />' },
160-
{ code: '<img alt="" aria-relevant />' },
144+
// IMG TESTS - no implicit role
145+
{ code: '<img alt="" aria-checked />' },
161146

162147
// this will have role of `img`
163148
{ code: '<img alt="foobar" aria-busy />' },
@@ -444,8 +429,8 @@ ruleTester.run('role-supports-aria-props', rule, {
444429
errors: [errorMessage('aria-checked', 'link', 'link', true)],
445430
},
446431
{
447-
code: '<img alt="" aria-checked />',
448-
errors: [errorMessage('aria-checked', 'presentation', 'img', true)],
432+
code: '<img alt="foobar" aria-checked />',
433+
errors: [errorMessage('aria-checked', 'img', 'img', true)],
449434
},
450435
{
451436
code: '<menu type="toolbar" aria-checked />',

src/util/implicitRoles/img.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function getImplicitRoleForImg(attributes) {
77
const alt = getProp(attributes, 'alt');
88

99
if (alt && getLiteralPropValue(alt) === '') {
10-
return 'presentation';
10+
return '';
1111
}
1212

1313
return 'img';

0 commit comments

Comments
 (0)