示例#1
0
文件: visitor.js 项目: jld/gecko-dev
function isOpeningJSXIdentifier(
  node: Node,
  ancestors: TraversalAncestors
): boolean {
  if (!t.isJSXIdentifier(node)) {
    return false;
  }

  for (let i = ancestors.length - 1; i >= 0; i--) {
    const { node: parent, key } = ancestors[i];

    if (t.isJSXOpeningElement(parent) && key === "name") {
      return true;
    } else if (!t.isJSXMemberExpression(parent) || key !== "object") {
      break;
    }
  }

  return false;
}
示例#2
0
文件: code.js 项目: elastic/kibana
export function isFormattedMessageElement(node) {
  return isJSXOpeningElement(node) && isJSXIdentifier(node.name, { name: 'FormattedMessage' });
}
示例#3
0
 const jsxOpeningElementNode = [...traverseNodes(AST.program.body)].find(node =>
   isJSXOpeningElement(node)