How to use the isJSXElement function from @babel/types
Find comprehensive JavaScript @babel/types.isJSXElement code examples handpicked from public code repositorys.
GitHub: didi/chameleon
72 73 74 75 76 77 78 79 80 81
} } // 配合安震,解析c-slider; exports.parseTagForSlider = function(path, type, options) { let node = path.node; if ((['wx', 'qq', 'baidu', 'alipay', 'tt'].includes(type)) && t.isJSXElement(node)) { let currentTag = node.openingElement.name.name; let targetTag = tagMap.wxTagMap[currentTag]; if (targetTag && currentTag !== targetTag) { node.openingElement.name.name = targetTag;
700
0
239
+ 13 other calls in file
GitHub: alijk-fe/motor-rax
184 185 186 187 188 189 190 191 192 193
[adapter.for]: t.jsxExpressionContainer(forNode), [adapter.forItem]: t.stringLiteral(forItem.name), [adapter.forIndex]: t.stringLiteral(renamedIndex.name), }; if (adapter.needTransformKey && t.isJSXElement(returnElPath.node)) { const attributes = returnElPath.node.openingElement.attributes; const keyIndex = findIndex(attributes, attr => t.isJSXIdentifier(attr.name, { name: 'key' })); if (keyIndex > -1) { listAttr.key = attributes[keyIndex].value;
663
11
1
+ 13 other calls in file
GitHub: xcodebuild/rax
158 159 160 161 162 163 164 165 166 167
// { foo } case 'Identifier': { const id = node.expression.name.trim(); if ( templateVariables[id] && t.isJSXElement(templateVariables[id].value) ) { // => <block a:if="xxx"> path.replaceWith(templateVariables[id].value); }
663
0
1
+ 3 other calls in file
GitHub: tapaswenipathak/rax
44 45 46 47 48 49 50 51 52 53
} }, generate(ret, parsed, options) { if (parsed[TEMPLATE_AST]) { const lastTemplateDefineIdx = findIndex(parsed[TEMPLATE_AST].children, (node) => t.isJSXElement(node) && node.openingElement.name.name !== 'template'); const templateDefineNodes = parsed[TEMPLATE_AST].children.splice(0, lastTemplateDefineIdx); ret.template = [ ...templateDefineNodes.map(node => genExpression(node, { comments: false,
663
0
1
+ 5 other calls in file
2 3 4 5 6 7 8 9 10 11
class ElementUtil { constructor(path) { this.path = path; this.node = path && path.node; this.isValid = t.isJSXElement(this.node); } /** * 返回标签名
13
89
4
+ 21 other calls in file
55 56 57 58 59 60 61 62 63
return storySource.substring(returnBody.start, returnBody.end); } function isImplicitReturn(bodyNode) { return t.isJSXElement(bodyNode) || t.isJSXFragment(bodyNode); } module.exports = { extractMetadata, extractDocgenInfo, validateDsmInfo };
3
13
21
+ 7 other calls in file
92 93 94 95 96 97 98 99 100 101
ThisExpression (thisPath) { const parentNode = thisPath.parentPath.parentPath.parent; const isValid = t.isExpressionStatement(parentNode) || t.isVariableDeclaration(parentNode) || t.isBlockStatement(parentNode) || t.isJSXElement(parentNode) || t.isCallExpression(parentNode) || (t.isJSXAttribute(parentNode) && !parentNode.name.name.startsWith('on')); if (isValid) {
65
1
1
GitHub: iammadanlal/next-blog
125 126 127 128 129 130 131 132 133 134 135 136
exports.isGlobalEl = isGlobalEl; var isStyledJsx = function isStyledJsx(_ref2) { var el = _ref2.node; return t.isJSXElement(el) && el.openingElement.name.name === 'style' && el.openingElement.attributes.some(function (attr) { return attr.name.name === _constants.STYLE_ATTRIBUTE; }); };
0
1
0
@babel/types.identifier is the most popular function in @babel/types (20936 examples)