From bdc24dfb1d5dc28ee2c8b03fdea58898080cc8f9 Mon Sep 17 00:00:00 2001 From: Kenny Wang and Matt Royal Date: Tue, 21 Jul 2015 11:44:22 -0700 Subject: [PATCH] [added] "picture" to the list of redundant words in img[alt] --- lib/__tests__/index-test.js | 6 ++++++ lib/assertions.js | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/__tests__/index-test.js b/lib/__tests__/index-test.js index a331954..4a7b513 100644 --- a/lib/__tests__/index-test.js +++ b/lib/__tests__/index-test.js @@ -177,6 +177,12 @@ describe('tags', () => { image of a cat; }); }); + + it('dissallows the word "picture" in the alt attribute', () => { + expectWarning(assertions.tags.img.REDUNDANT_ALT.msg, () => { + picture of a cat; + }); + }); }); describe('a', () => { diff --git a/lib/assertions.js b/lib/assertions.js index 37a6174..e345d1f 100644 --- a/lib/assertions.js +++ b/lib/assertions.js @@ -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')); } } }