1 | import * as ts from 'typescript';
|
2 | import { getJsxAttributesFromJsxElement, getStringLiteral } from '../JsxAttribute';
|
3 |
|
4 | const typeString: string = 'type';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function 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 |
|
30 | export { getImplicitRoleForMenuitem as menuitem };
|