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(provide): provide should default to parentVal during merging, fix #6436 #6473

Merged
merged 2 commits into from
Sep 5, 2017
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
2 changes: 1 addition & 1 deletion src/core/util/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions test/unit/features/options/inject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})