/
githubmirror
/
taro
Обзор
Документация
Войти
/
githubmirror
/
taro
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/babel-plugin-transform-solid-jsx/src/shared/fragment.js
20 строк
848 B
phy-lei
feat: [4.x]完成solid-componets-library 和 babel-plugin-transform-solid-jsx 两个包的开发 (#15539)
03 июн 2024, 18:40
Не верифицирован
03 июн 2024, 18:40
c768863
Код
Авторство
О чём код?
import * as t from '@babel/types' import { decode } from 'html-entities' import { getCreateTemplate, transformNode } from './transform' import { filterChildren, trimWhitespace } from './utils' export default function transformFragmentChildren(children, results, config) { const filteredChildren = filterChildren(children) const childNodes = filteredChildren.reduce((memo, path) => { if (t.isJSXText(path.node)) { const v = decode(trimWhitespace(path.node.extra.raw)) if (v.length) memo.push(t.stringLiteral(v)) } else { const child = transformNode(path, { topLevel: true, fragmentChild: true, lastElement: true }) memo.push(getCreateTemplate(config, path, child)(path, child, true)) } return memo }, []) results.exprs.push(childNodes.length === 1 ? childNodes[0] : t.arrayExpression(childNodes)) }