Skip to content

Commit

Permalink
fix: The behavior of development and production merge should be consi…
Browse files Browse the repository at this point in the history
…stent. (#694)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
ygj6 and antfu committed May 19, 2021
1 parent 8c27d80 commit 7ca7010
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/instance.ts
Expand Up @@ -47,7 +47,12 @@ export function asVmProperty(
},
})
} else {
vm._data[propName] = propValue
proxy(vm._data, propName, {
get: () => propValue,
set: (val: any) => {
propValue = val
},
})
}
})
}
Expand Down
44 changes: 44 additions & 0 deletions test/setup.spec.js
Expand Up @@ -898,6 +898,50 @@ describe('setup', () => {
expect(vm.$el.textContent).toBe('2')
})

// #679
it('should work merge with object in development', async () => {
global.__DEV__ = true
const vm = new Vue({
template: '<div>{{ data.id }}</div>',
setup() {
const data = reactive({
id: 42,
})
return { data }
},
data() {
return {
data: { id: 1 },
}
},
}).$mount()

await nextTick()
expect(vm.$el.textContent).toBe('1')
})

// #679
it('should work merge with object in production', async () => {
global.__DEV__ = false
const vm = new Vue({
template: '<div>{{ data.id }}</div>',
setup() {
const data = reactive({
id: 42,
})
return { data }
},
data() {
return {
data: { id: 1 },
}
},
}).$mount()

await nextTick()
expect(vm.$el.textContent).toBe('1')
})

// #683 #603 #580
it('should update directly when adding attributes to a reactive object', async () => {
const vm = new Vue({
Expand Down

0 comments on commit 7ca7010

Please sign in to comment.