mirror of https://github.com/vuejs/vue.git
fix(provide): provide should default to parentVal during merging (#6473)
fix #6436
This commit is contained in:
parent
a67b795b36
commit
3c216755f6
|
@ -96,7 +96,7 @@ export function mergeDataOrFn (
|
|||
: childVal
|
||||
const defaultData = typeof parentVal === 'function'
|
||||
? parentVal.call(vm)
|
||||
: undefined
|
||||
: parentVal
|
||||
if (instanceData) {
|
||||
return mergeData(instanceData, defaultData)
|
||||
} else {
|
||||
|
|
|
@ -545,4 +545,24 @@ describe('Options provide/inject', () => {
|
|||
|
||||
expect(vm.$el.textContent).toBe(`foo: foo injected, bar: bar injected`)
|
||||
})
|
||||
|
||||
it('merge provide with object syntax when using Vue.extend', () => {
|
||||
const child = {
|
||||
inject: ['foo'],
|
||||
template: `<span/>`,
|
||||
created () {
|
||||
injected = this.foo
|
||||
}
|
||||
}
|
||||
const Ctor = Vue.extend({
|
||||
provide: { foo: 'foo' },
|
||||
render (h) {
|
||||
return h(child)
|
||||
}
|
||||
})
|
||||
|
||||
new Ctor().$mount()
|
||||
|
||||
expect(injected).toEqual('foo')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue