Skip to content

Commit

Permalink
fix(transformer): 多级循环作用域处理有误,close #2814
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Apr 22, 2019
1 parent 7c02612 commit 5620df1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/taro-transformer-wx/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,16 @@ export class RenderParser {
if (path.findParent(p => this.loopCallees.has(p.node))) {
return
}
const parentCondition = path.findParent(p => p.isConditionalExpression() || p.isLogicalExpression())
if (parentCondition) {
const varDecl = parentCondition.findParent(p => p.isVariableDeclarator())
if (varDecl && varDecl.isVariableDeclarator()) {
const init = varDecl.node.id
if (t.isIdentifier(init) && init.name.startsWith(LOOP_STATE)) {
return
}
}
}
const replacement = t.memberExpression(
t.identifier(item.name),
path.node
Expand Down

0 comments on commit 5620df1

Please sign in to comment.