提交 082d5b17 编写于 作者: Q qiang

fix(mp): 修复小程序连用多个逻辑表达式编译出错的问题(question/129122)

上级 abd34e00
......@@ -811,6 +811,11 @@ describe('mp:compiler-extra', () => {
'<block wx:if="{{show}}"><view><block wx:if="{{$root.g0}}"><view>{{$root.m0}}</view></block></view></block>',
'with(this){var g0=show?test.test(key)&&test2(key):null;var m0=show&&g0?getValue(key):null;$mp.data=Object.assign({},{$root:{g0:g0,m0:m0}})}'
)
assertCodegen(
'<view v-if="test&&!test.test(key1)&&!test.test(key2)">{{getValue(key)}}</view>',
'<block wx:if="{{$root.g0}}"><view>{{$root.m0}}</view></block>',
'with(this){var g0=test&&!test.test(key1)&&!test.test(key2);var m0=g0?getValue(key):null;$mp.data=Object.assign({},{$root:{g0:g0,m0:m0}})}'
)
assertCodegen(
'<view v-for="(item,index) in list" :key="index"><view v-if="item">{{getValue(item)}}</view></view>',
'<block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view><block wx:if="{{item.$orig}}"><view>{{item.m0}}</view></block></view></block>',
......
......@@ -216,7 +216,11 @@ module.exports = {
// event
return path.skip()
}
path = path.findParent((path) => path.isLogicalExpression()) || path
let newPath = path
while (newPath) {
path = newPath
newPath = path.findParent((path) => path.isLogicalExpression())
}
path.skip()
if (path.findParent((path) => path.shouldSkip)) {
return
......@@ -251,7 +255,11 @@ module.exports = {
t.isMemberExpression(callee) // message.split('').reverse().join('')
) {
// Object.assign...
path = path.findParent((path) => path.isLogicalExpression()) || path
let newPath = path
while (newPath) {
path = newPath
newPath = path.findParent((path) => path.isLogicalExpression())
}
path.skip()
if (path.findParent((path) => path.shouldSkip)) {
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册