提交 757f34b5 编写于 作者: Q qiang

fix: @babel/template with syntacticPlaceholders (question/170722)

上级 bf158b40
......@@ -427,7 +427,7 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false,
const paramsUid = funcPath.scope.generateDeclaredUidIdentifier().name
const dataset = ATTR_DATA_EVENT_PARAMS.substring(5)
const code = `var ${datasetUid}=${argumentsName}[${argumentsName}.length-1].currentTarget.dataset,${paramsUid}=${datasetUid}.${dataset.replace(/-([a-z])/, (_, str) => str.toUpperCase())}||${datasetUid}['${dataset}'],${params.map(item => `${item}=${paramsUid}.${item}`).join(',')}`
funcPath.node.body.body.unshift(template(code)())
funcPath.node.body.body.unshift(template(code, { syntacticPlaceholders: true })())
}
methods.push(addEventExpressionStatement(funcPath, state, isComponent, isNativeOn))
}
......
......@@ -166,7 +166,7 @@ function replaceMemberExpression (stringLiteral, state) {
code = newCode
}
})
const buildRequire = babelTemplate(code)
const buildRequire = babelTemplate(code, { syntacticPlaceholders: true })
if (Object.keys(options).length) {
const ast = buildRequire(options)
return ast.expression
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册