a11y: Fix img-reduntant-alt bug

pull/4771/head
Doga Genc 5 years ago
parent b9f83fd295
commit 28a292d03f

@ -438,7 +438,7 @@ export default class Element extends Node {
if (href_attribute) { if (href_attribute) {
const href_value = href_attribute.get_static_value(); const href_value = href_attribute.get_static_value();
if (href_value === '' || href_value === '#' || /^\W*javascript:/i.test(href_value)) { if (href_value === '' || href_value === '#' || /^\W*javascript:/i.test(href_value)) {
component.warn(href_attribute, { component.warn(href_attribute, {
code: `a11y-invalid-attribute`, code: `a11y-invalid-attribute`,
@ -484,11 +484,11 @@ export default class Element extends Node {
const aria_hidden_attribute = attribute_map.get('aria-hidden'); const aria_hidden_attribute = attribute_map.get('aria-hidden');
const aria_hidden_exist = aria_hidden_attribute && aria_hidden_attribute.get_static_value(); const aria_hidden_exist = aria_hidden_attribute && aria_hidden_attribute.get_static_value();
if (alt_attribute && !aria_hidden_exist) { if (alt_attribute && !aria_hidden_exist) {
const alt_value = alt_attribute.get_static_value(); const alt_value = alt_attribute.get_static_value();
if (alt_value.match(/\b(image|picture|photo)\b/i)) { if (alt_value && alt_value.match(/\b(image|picture|photo)\b/i)) {
component.warn(this, { component.warn(this, {
code: `a11y-img-redundant-alt`, code: `a11y-img-redundant-alt`,
message: `A11y: Screenreaders already announce <img> elements as an image.` message: `A11y: Screenreaders already announce <img> elements as an image.`

Loading…
Cancel
Save