How to use the jsxElement function from @babel/types
Find comprehensive JavaScript @babel/types.jsxElement code examples handpicked from public code repositorys.
77 78 79 80 81 82 83 84 85 86
return prettierFormat(code); }; const wrapJSXNode = (node, importIdentifier, name, value) => { const jsxNode = t.jsxElement( t.jsxOpeningElement(t.jsxIdentifier(importIdentifier), [ t.jsxAttribute(t.jsxIdentifier(name), t.JSXExpressionContainer(t.Identifier(value))), ]), t.jsxClosingElement(t.jsxIdentifier(importIdentifier)),
124 125 126 127 128 129 130 131 132 133
} if (match) { node.openingElement.selfClosing = false; node.closingElement = t.jsxClosingElement(node.openingElement.name); node.children = childrenData.map(({ name, props = {} }) => { return t.jsxElement( t.jsxOpeningElement(t.jsxIdentifier(name), Object.keys(props).map((key) => { const value = props[key]; return t.jsxAttribute(t.jsxIdentifier(key), t.stringLiteral(value)); }), true),
+ 5 other calls in file
41 42 43 44 45 46 47 48 49 50
if (typeof max !== 'undefined') { attrArray.push(t.jsxAttribute(t.jsxIdentifier('max'), t.jsxExpressionContainer(t.numericLiteral(item.max)))) } return [ t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier('InputNumber'), attrArray, true), null, []) ] } function getTextareaJsxExpression (item) { const { placeholder = '' } = item
+ 29 other calls in file
11 12 13 14 15 16 17 18 19 20
const formArray = [blankLine] DataSchema.filter(item => renderInForm(item, 'edit')).forEach(item => { formArray.push(genFormItemUtil(item, false, true, Config), blankLine) }) const ast = t.jsxElement( t.jsxOpeningElement(t.jsxIdentifier('Form'), []), t.jsxClosingElement(t.jsxIdentifier('Form')), formArray )
+ 2 other calls in file
99 100 101 102 103 104 105 106 107 108
exports.ExpressionStatementTaro = function ExpressionStatementTaro() { const callee = t.memberExpression(t.Identifier('Taro'), t.identifier('render')) const arguments = [] const openingElement = t.jsxOpeningElement(t.jsxIdentifier('App'), [], true) const jsxElement = t.jsxElement(openingElement, null, [], true) const CallExpression = t.callExpression(t.memberExpression(t.Identifier('document'), t.identifier('getElementById')), [t.stringLiteral('app')]) arguments.push(jsxElement) arguments.push(CallExpression) const expression = t.callExpression(callee, arguments)
GitHub: blikblum/to-htm
10 11 12 13 14 15 16 17 18 19
exports.createFragment = function (children, attributes) { if (attributes === void 0) { attributes = []; } var fragmentMemberExpression = Babel.jsxMemberExpression(Babel.jsxIdentifier('React'), Babel.jsxIdentifier('Fragment')); var openingFragment = Babel.jsxOpeningElement(fragmentMemberExpression, attributes); var closingFragment = Babel.jsxClosingElement(fragmentMemberExpression); return Babel.jsxElement(openingFragment, closingFragment, children, false); }; /** * Coverts AttrNode to JSXAttribute */
+ 3 other calls in file
GitHub: wso2/oxygen-ui
82 83 84 85 86 87 88 89 90 91 92 93 94
if (children.length > 0) { return t.jsxElement(openingElement, closingElement, children, false); } return t.jsxElement(openingElement, closingElement, [], true); } throw new Error(`Unknown type: ${nodeClone.type}`); };
48 49 50 51 52 53 54 55 56 57
const children = (0, _all.default)(h, node); const selfClosing = children.length === 0; const name = _mappings.ELEMENT_TAG_NAME_MAPPING[node.tagName] || node.tagName; const openingElement = t.jsxOpeningElement(t.jsxIdentifier(name), (0, _getAttributes.default)(node), selfClosing); const closingElement = !selfClosing ? t.jsxClosingElement(t.jsxIdentifier(name)) : null; const jsxElement = t.jsxElement(openingElement, closingElement, children); if (parent.type === 'root') { return t.expressionStatement(jsxElement); }
GitHub: jackromo888/octicons
![jackromo888 profile picture](/jackromo888.png?size=40)
156 157 158 159 160 161 162 163 164 165
}) const openingElement = t.jsxOpeningElement(t.jsxIdentifier(node.name), attrs, children.length === 0) const closingElement = t.jsxClosingElement(t.jsxIdentifier(node.name)) if (children.length > 0) { return t.jsxElement(openingElement, closingElement, children, false) } return t.jsxElement(openingElement, closingElement, [], true) }
+ 3 other calls in file
74 75 76 77 78 79 80 81 82 83
pragma: "jsx", pragmaFrag: "Fragment" }]] }); let genNewNode = (matches, path) => { return t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("uc-data"), [t.jsxAttribute(t.jsxIdentifier("_listen"), t.jsxExpressionContainer(t.objectExpression(matches.map((v, i) => { return t.objectProperty(t.identifier("_bK" + i), t.identifier(v)); }))))]), t.jsxClosingElement(t.jsxIdentifier("uc-data")), [path]); }; let isAttr = (path, el) => {
+ 277 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)