mirror of
https://gitee.com/vuejs/vue.git
synced 2024-11-30 02:57:43 +08:00
parent
f9f74231a2
commit
ebcef58645
@ -80,7 +80,7 @@ function checkIdentifier (
|
||||
) {
|
||||
if (typeof ident === 'string') {
|
||||
try {
|
||||
new Function(`var ${ident}`)
|
||||
new Function(`var ${ident}=_`)
|
||||
} catch (e) {
|
||||
errors.push(`invalid ${type} "${ident}" in expression: ${text.trim()}`)
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ describe('Directive v-for', () => {
|
||||
}).then(done)
|
||||
})
|
||||
|
||||
it('strings', done => {
|
||||
it('should work with strings', done => {
|
||||
const vm = new Vue({
|
||||
data: {
|
||||
text: 'foo'
|
||||
@ -463,4 +463,21 @@ describe('Directive v-for', () => {
|
||||
expect(vm.$el.textContent).toMatch('f.o.o.b.a.r.')
|
||||
}).then(done)
|
||||
})
|
||||
|
||||
const supportsDeconstruct = (() => {
|
||||
try {
|
||||
new Function('var { foo } = bar')
|
||||
return true
|
||||
} catch (e) {}
|
||||
})()
|
||||
|
||||
if (supportsDeconstruct) {
|
||||
it('should support deconstruct syntax in alias position', () => {
|
||||
const vm = new Vue({
|
||||
data: { list: [{ foo: 'hi' }] },
|
||||
template: '<div><div v-for="({ foo }, i) in list">{{ foo }}{{ i }}</div></div>'
|
||||
}).$mount()
|
||||
expect(vm.$el.textContent).toBe('hi0')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user