提交 72dc6375 编写于 作者: Q qiang

fix(mp): TemplateElement with quote

上级 5890642c
......@@ -60,11 +60,25 @@ describe('mp:compiler-mp-weixin', () => {
'<view data-text="{{$root.a0}}"></view>',
`with(this){var a0=text+"'";$mp.data=Object.assign({},{$root:{a0:a0}})}`
)
assertCodegen(
'<view :data-text="`${text}\'`"></view>',
'<view data-text="{{$root.a0}}"></view>',
'with(this){var a0=`${text}\'`;$mp.data=Object.assign({},{$root:{a0:a0}})}'
)
assertCodegen(
`<view>{{text+'\\''}}</view>`,
'<view>{{$root.t0}}</view>',
`with(this){var t0=text+"'";$mp.data=Object.assign({},{$root:{t0:t0}})}`
)
assertCodegen(
'<view>{{`${text}\'`}}</view>',
'<view>{{$root.t0}}</view>',
'with(this){var t0=`${text}\'`;$mp.data=Object.assign({},{$root:{t0:t0}})}'
)
assertCodegen(
'<view>{{`${text}"`}}</view>',
`<view>{{text+'"'}}</view>`
)
assertCodegen(
`<view>{{text+"\\""}}</view>`,
'<view>{{$root.t0}}</view>',
......
......@@ -255,6 +255,12 @@ function hasEscapeQuote (path) {
has = true
path.stop()
}
},
TemplateElement (path) {
if (path.node.value.cooked.includes('\'')) {
has = true
path.stop()
}
}
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册