mirror of https://github.com/vuejs/core.git
parent
ecd97ee6e4
commit
c7efb967ca
|
@ -19,6 +19,7 @@ export function deepMergeData(
|
||||||
to[key] = fromVal
|
to[key] = fromVal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return to
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mergeDataOption(to: any, from: any) {
|
export function mergeDataOption(to: any, from: any) {
|
||||||
|
|
|
@ -47,12 +47,15 @@ test('data deep merge', () => {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
foo: {
|
foo: {
|
||||||
bar: 1
|
bar: 1
|
||||||
}
|
},
|
||||||
|
selfData: 3
|
||||||
}),
|
}),
|
||||||
template: `{{ foo }}`
|
template: `{{ { selfData, foo } }}`
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
expect(vm.$el.textContent).toBe(JSON.stringify({ baz: 2, bar: 1 }, null, 2))
|
expect(vm.$el.textContent).toBe(
|
||||||
|
JSON.stringify({ selfData: 3, foo: { baz: 2, bar: 1 } }, null, 2)
|
||||||
|
)
|
||||||
expect(
|
expect(
|
||||||
(deprecationData[DeprecationTypes.OPTIONS_DATA_MERGE].message as Function)(
|
(deprecationData[DeprecationTypes.OPTIONS_DATA_MERGE].message as Function)(
|
||||||
'foo'
|
'foo'
|
||||||
|
@ -60,6 +63,26 @@ test('data deep merge', () => {
|
||||||
).toHaveBeenWarned()
|
).toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #3852
|
||||||
|
test('data deep merge w/ extended constructor', () => {
|
||||||
|
const App = Vue.extend({
|
||||||
|
template: `<pre>{{ { mixinData, selfData } }}</pre>`,
|
||||||
|
mixins: [{ data: () => ({ mixinData: 'mixinData' }) }],
|
||||||
|
data: () => ({ selfData: 'selfData' })
|
||||||
|
})
|
||||||
|
const vm = new App().$mount()
|
||||||
|
expect(vm.$el.textContent).toBe(
|
||||||
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
mixinData: 'mixinData',
|
||||||
|
selfData: 'selfData'
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test('beforeDestroy/destroyed', async () => {
|
test('beforeDestroy/destroyed', async () => {
|
||||||
const beforeDestroy = jest.fn()
|
const beforeDestroy = jest.fn()
|
||||||
const destroyed = jest.fn()
|
const destroyed = jest.fn()
|
||||||
|
|
Loading…
Reference in New Issue