diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index b9d2672168..24bf6c8558 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -486,14 +486,9 @@ export default class Element extends Node { const aria_hidden_exist = aria_hidden_attribute && aria_hidden_attribute.get_static_value(); if (alt_attribute && !aria_hidden_exist) { - const invalid_words = ['image', 'photo', 'picture']; const alt_value = alt_attribute.get_static_value(); - const contain_invalid_word = invalid_words.some(word => - alt_value.toLowerCase().includes(word) - ); - - if (contain_invalid_word) { + if (alt_value.toLowerCase().match(/\b(image|picture|photo)\b/g)) { component.warn(this, { code: `a11y-img-redundant-alt`, message: `A11y: Screenreaders already announce elements as an image.` diff --git a/test/validator/samples/a11y-img-redundant-alt/input.svelte b/test/validator/samples/a11y-img-redundant-alt/input.svelte index 06d8ef06d1..3ba029844d 100644 --- a/test/validator/samples/a11y-img-redundant-alt/input.svelte +++ b/test/validator/samples/a11y-img-redundant-alt/input.svelte @@ -2,4 +2,6 @@ Picture of me taking a photo of an image Photo of foo being weird. Image of me at a bar! -Picture of baz fixing a bug. \ No newline at end of file +Picture of baz fixing a bug. +Plant doing photosynthesis in the afternoon +Picturesque food \ No newline at end of file