Skip to content

Commit

Permalink
fix(taroize): class 内部 wx. 开头的函数不会转换为 Taro.func()
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Dec 3, 2018
1 parent 0c894bd commit 5d01b3c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/taroize/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ function parsePage (
refId?: Set<string>
) {
const stateKeys: string[] = []
path.traverse({
CallExpression (path) {
const callee = path.get('callee')
if (callee.isIdentifier()) {
const name = callee.node.name
if (name === 'getApp' || name === 'getCurrentPages') {
callee.replaceWith(
t.memberExpression(t.identifier('Taro'), callee.node)
)
}
}
if (callee.isMemberExpression()) {
const object = callee.get('object')
if (object.isIdentifier({ name: 'wx' })) {
object.replaceWith(t.identifier('Taro'))
}
}
}
})
if (refId) {
refId.forEach(id => {
if (!stateKeys.includes(id)) {
Expand Down

0 comments on commit 5d01b3c

Please sign in to comment.