1 | import * as ts from 'typescript';
|
2 | import { getJsxAttributesFromJsxElement, getStringLiteral } from '../JsxAttribute';
|
3 |
|
4 | const altString: string = 'alt';
|
5 |
|
6 | /**
|
7 | * @Returns the implicit role for an img tag.
|
8 | */
|
9 | function 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 |
|
19 | export { getImplicitRoleForImg as img };
|