UNPKG

486 BPlain TextView Raw
1import * as ts from 'typescript';
2import { getJsxAttributesFromJsxElement, getStringLiteral } from '../JsxAttribute';
3
4const altString: string = 'alt';
5
6/**
7 * @Returns the implicit role for an img tag.
8 */
9function getImplicitRoleForImg(node: ts.Node): string {
10 const alt: ts.JsxAttribute = getJsxAttributesFromJsxElement(node)[altString];
11
12 if (alt && getStringLiteral(alt)) {
13 return 'img';
14 }
15
16 return 'presentation';
17}
18
19export { getImplicitRoleForImg as img };