Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The behavior of development and production merge should be consistent. #694

Merged
merged 4 commits into from May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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