Skip to content

Commit

Permalink
fix(transformer): 即便在类中没有找到方法也要加到 $events, close #563
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Sep 6, 2018
1 parent 575495e commit 33c8c38
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/taro-transformer-wx/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,15 @@ export class RenderParser {
name.name.startsWith('on')
) {
if (t.isJSXExpressionContainer(value)) {
let methodName = findMethodName(value.expression)
const methodName = findMethodName(value.expression)
methodName && this.usedEvents.add(methodName)
if (this.methods.has(methodName)) {
const method = this.methods.get(methodName)
if (method && t.isIdentifier(method.node.key)) {
this.usedEvents.add(methodName)
} else if (method === null) {
this.usedEvents.add(methodName)
}
// if (method && t.isIdentifier(method.node.key)) {
// this.usedEvents.add(methodName)
// } else if (method === null) {
// this.usedEvents.add(methodName)
// }
if (!generate(value.expression).code.includes('.bind')) {
path.node.value = t.stringLiteral(`${methodName}`)
}
Expand Down

0 comments on commit 33c8c38

Please sign in to comment.