UNPKG

504 BPlain TextView Raw
1import * as ts from 'typescript';
2import { isJsxElement } from '../TypeGuard';
3
4/**
5 * @Returns the implicit role for an li tag.
6 */
7function getImplicitRoleForLi(node: ts.Node): string {
8 const parentNode: ts.Node = node.parent;
9 let parentTagName: string;
10
11 if (isJsxElement(parentNode)) {
12 parentTagName = parentNode.openingElement.tagName.getText();
13 }
14 return parentTagName === 'ol' || parentTagName === 'ul' ? 'listitem' : undefined;
15}
16
17export { getImplicitRoleForLi as li };