UNPKG

620 BPlain TextView Raw
1import * as ts from 'typescript';
2import { getJsxAttributesFromJsxElement, getStringLiteral } from '../JsxAttribute';
3
4const typeString: string = 'type';
5
6/**
7 * @Returns the implicit role for a menu tag.
8 */
9function getImplicitRoleForMenu(node: ts.Node): string {
10 const typeAttribute: ts.JsxAttribute = getJsxAttributesFromJsxElement(node)[typeString];
11
12 if (typeAttribute) {
13 const value: string = getStringLiteral(typeAttribute) || undefined;
14
15 return value && value.toUpperCase() === 'TOOLBAR' ? 'toolbar' : undefined;
16 }
17
18 return undefined;
19}
20
21export { getImplicitRoleForMenu as menu };