Skip to content

Commit

Permalink
Merge pull request #82 from pivotal-cf/img_alt_checks_for_picture
Browse files Browse the repository at this point in the history
[added] "picture" to the list of redundant words in img[alt]
  • Loading branch information
kloots committed Aug 18, 2015
2 parents 39ff58d + bdc24df commit 6aa203d
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 @@ -179,6 +179,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 6aa203d

Please sign in to comment.