parent
ecd97ee6e4
commit
c7efb967ca
@ -19,6 +19,7 @@ export function deepMergeData(
|
||||
to[key] = fromVal
|
||||
}
|
||||
}
|
||||
return to
|
||||
}
|
||||
|
||||
export function mergeDataOption(to: any, from: any) {
|
||||
|
@ -47,12 +47,15 @@ test('data deep merge', () => {
|
||||
data: () => ({
|
||||
foo: {
|
||||
bar: 1
|
||||
}
|
||||
},
|
||||
selfData: 3
|
||||
}),
|
||||
template: `{{ foo }}`
|
||||
template: `{{ { selfData, foo } }}`
|
||||
}).$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(
|
||||
(deprecationData[DeprecationTypes.OPTIONS_DATA_MERGE].message as Function)(
|
||||
'foo'
|
||||
@ -60,6 +63,26 @@ test('data deep merge', () => {
|
||||
).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 () => {
|
||||
const beforeDestroy = jest.fn()
|
||||
const destroyed = jest.fn()
|
||||
|
Loading…
Reference in New Issue
Block a user