UNPKG

851 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 menuitem tag.
8 */
9function getImplicitRoleForMenuitem(node: ts.Node): string {
10 const typeAttribute: ts.JsxAttribute = getJsxAttributesFromJsxElement(node)[typeString];
11
12 if (typeAttribute) {
13 const value: string = getStringLiteral(typeAttribute) || '';
14
15 switch (value.toUpperCase()) {
16 case 'COMMAND':
17 return 'menuitem';
18 case 'CHECKBOX':
19 return 'menuitemcheckbox';
20 case 'RADIO':
21 return 'menuitemradio';
22 default:
23 return undefined;
24 }
25 }
26
27 return undefined;
28}
29
30export { getImplicitRoleForMenuitem as menuitem };