yhtml5-test
Version:
A test framework for front-end projects
15 lines (11 loc) • 317 B
JavaScript
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';
/**
* Returns the implicit role for an img tag.
*/
export default function getImplicitRoleForImg(attributes) {
const alt = getProp(attributes, 'alt');
if (alt && getLiteralPropValue(alt) === '') {
return 'presentation';
}
return 'img';
}