Skip to content

Commit

Permalink
fix(transformer): 动态循环组件 return stateName 标识符
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Jul 6, 2018
1 parent 57ee230 commit ab67b7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/taro-transformer-wx/src/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class Transformer {
},
JSXElement (path) {
const id = path.node.openingElement.name
debugger
if (
t.isJSXIdentifier(id) &&
!DEFAULT_Component_SET.has(id.name) &&
Expand Down Expand Up @@ -308,11 +309,15 @@ class Transformer {
? ary[2] : ary[1]
}
const stateNameDecl = buildConstVariableDeclaration('stateName', t.stringLiteral(stateName))
const stateGetter = t.callExpression(t.identifier(INTERNAL_SAFE_GET), [
t.memberExpression(t.thisExpression(), t.identifier('state')),
t.identifier('stateName')
])
const returnStatement = t.returnStatement(
t.objectExpression([
t.objectProperty(t.identifier('stateName'), t.identifier('stateName')),
t.objectProperty(t.identifier('loopComponents'), t.callExpression(t.identifier(INTERNAL_DYNAMIC), [
t.thisExpression(), t.identifier('nodes'), buildInternalSafeGet(stateName), t.stringLiteral(uuid)
t.thisExpression(), t.identifier('nodes'), stateGetter, t.stringLiteral(uuid)
]))
])
)
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-transformer-wx/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rules": {
"no-console": true,
"no-unused-variable": false,
"member-ordering": false
"member-ordering": false,
"no-debugger": true
}
}

0 comments on commit ab67b7b

Please sign in to comment.