Skip to content

Commit

Permalink
refactor(transformer): 快应用 $$event 更名为 privateTaroEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Jul 11, 2019
1 parent 6b48d95 commit ed6de3b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/taro-transformer-wx/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2243,13 +2243,13 @@ export class RenderParser {

setCustomEvent () {
const classPath = this.renderPath.findParent(isClassDcl) as NodePath<t.ClassDeclaration>
const eventPropName = '$$events'
const eventPropName = Adapter.type === Adapters.quickapp ? 'privateTaroEvent' : '$$events'
const body = classPath.node.body.body.find(b => t.isClassProperty(b) && b.key.name === eventPropName) as t.ClassProperty
const usedEvents = Array.from(this.usedEvents).map(s => t.stringLiteral(s))
if (body && t.isArrayExpression(body.value)) {
body.value = t.arrayExpression(uniq(body.value.elements.concat(usedEvents)))
} else {
let classProp = t.classProperty(t.identifier('$$events'), t.arrayExpression(usedEvents)) as any // babel 6 typing 没有 static
let classProp = t.classProperty(t.identifier(eventPropName), t.arrayExpression(usedEvents)) as any // babel 6 typing 没有 static
classProp.static = true
classPath.node.body.body.unshift(classProp)
}
Expand Down

0 comments on commit ed6de3b

Please sign in to comment.