Skip to content

Commit

Permalink
[added] "picture" to the list of redundant words in img[alt]
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-royal committed Jul 21, 2015
1 parent 9a28109 commit bdc24df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ describe('tags', () => {
<img src="cat.gif" alt="image of a cat"/>;
});
});

it('dissallows the word "picture" in the alt attribute', () => {
expectWarning(assertions.tags.img.REDUNDANT_ALT.msg, () => {
<img src="cat.gif" alt="picture of a cat"/>;
});
});
});

describe('a', () => {
Expand Down
6 changes: 3 additions & 3 deletions lib/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ exports.tags = {

REDUNDANT_ALT: {
// TODO: have some way to set localization strings to match against
msg: 'Screen-readers already announce `img` tags as an image, you don\'t need to use the word "image" in the description',
msg: 'Screen-readers already announce `img` tags as an image, you don\'t need to use the word "image" or "picture" in the description',
test (tagName, props, children) {
if (isHiddenFromAT(props))
if (isHiddenFromAT(props) || !hasAlt(props))
return true;

return !(hasAlt(props) && props.alt.match('image'));
return !(props.alt.match('image') || props.alt.match('picture'));
}
}
}
Expand Down

0 comments on commit bdc24df

Please sign in to comment.