Skip to content

Commit

Permalink
fix(transformer): 加强对 JSX children 的判定
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Jun 21, 2018
1 parent 513243b commit a2335f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/taro-transformer-wx/.gitignore
Expand Up @@ -7,4 +7,5 @@ yarn-error.log
_book
.idea
lib
t.js
t.js
tt.js
10 changes: 7 additions & 3 deletions packages/taro-transformer-wx/src/render.ts
Expand Up @@ -161,11 +161,15 @@ export class RenderParser {
t.isReturnStatement(parentNode) ||
(
isReturnStatement &&
!t.isArrowFunctionExpression(parentNode) &&
!jsxElementPath.findParent(p => p.isJSXExpressionContainer())
!t.isArrowFunctionExpression(parentNode)
)
) {
if (!isFinalReturn) {
let isChildren = false
this.loopComponents.forEach((component) => {
isChildren = !!jsxElementPath.findParent(p => p === component)
})
const JSXExpr = jsxElementPath.findParent(p => p.isJSXExpressionContainer())
if (!isFinalReturn && (!isChildren || isContainFunction(JSXExpr))) {
const callExpr = parentPath.findParent(p => p.isCallExpression())
if (callExpr.isCallExpression()) {
const callee = callExpr.node.callee
Expand Down

0 comments on commit a2335f1

Please sign in to comment.