Skip to content

Commit

Permalink
fix(transformer): 某些情况循环中使用 stopPropagation 报错
Browse files Browse the repository at this point in the history
close #3946
  • Loading branch information
yuche committed Jul 26, 2019
1 parent cd84e67 commit 5b02527
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/taro-transformer-wx/src/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { isTestEnv } from './env'
import { Status } from './functional'
import { injectRenderPropsEmiter } from './render-props'

const stopPropagationExpr = require('babel-template')(`typeof e === 'object' && e.stopPropagation && e.stopPropagation()`)

type ClassMethodsMap = Map<string, NodePath<t.ClassMethod | t.ClassProperty>>

function buildConstructor () {
Expand Down Expand Up @@ -294,7 +296,7 @@ class Transformer {
)
classBody.push(
t.classMethod('method', t.identifier(anonymousFuncName), [t.identifier(indexKey), t.restElement(t.identifier('e'))], t.blockStatement([
isCatch ? t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('e'), t.identifier('stopPropagation')), [])) : t.emptyStatement(),
isCatch ? stopPropagationExpr() : t.emptyStatement(),
t.returnStatement(t.logicalExpression('&&', arrayFunc, t.callExpression(arrayFunc, [t.spreadElement(t.identifier('e'))])))
]))
)
Expand Down

0 comments on commit 5b02527

Please sign in to comment.