Skip to content

Commit

Permalink
fix erroneous a11y warning with input type='image' (sveltejs#3331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Aug 2, 2019
1 parent 981f30d commit 276eb8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/compiler/compile/nodes/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,12 @@ export default class Element extends Node {
if (this.name === 'input') {
const type = attribute_map.get('type');
if (type && type.get_static_value() === 'image') {
should_have_attribute(
this,
['alt', 'aria-label', 'aria-labelledby'],
'input type="image"'
);
const required_attributes = ['alt', 'aria-label', 'aria-labelledby'];
const has_attribute = required_attributes.some(name => attribute_map.has(name));

if (!has_attribute) {
should_have_attribute(this, required_attributes, 'input type="image"');
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/validator/samples/a11y-alt-text/input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

<object></object>

<input type='image'>
<input type='image'>

<input type='image' alt='hey'>

0 comments on commit 276eb8e

Please sign in to comment.