Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/instance/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function initInjections (vm: Component) {
const provideKey = isArray ? key : inject[key]
let source = vm
while (source) {
if (source._provided && source._provided[provideKey]) {
if (source._provided && provideKey in source._provided) {
vm[key] = source._provided[provideKey]
break
}
Expand Down
16 changes: 8 additions & 8 deletions test/unit/features/options/inject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Options provide/inject', () => {
template: `<child/>`,
provide: {
foo: 1,
bar: 2
bar: false
},
components: {
child: {
Expand All @@ -32,15 +32,15 @@ describe('Options provide/inject', () => {
}
}).$mount()

expect(injected).toEqual([1, 2])
expect(injected).toEqual([1, false])
})

it('should use closest parent', () => {
new Vue({
template: `<child/>`,
provide: {
foo: 1,
bar: 2
bar: null
},
components: {
child: {
Expand All @@ -55,15 +55,15 @@ describe('Options provide/inject', () => {
}
}).$mount()

expect(injected).toEqual([3, 2])
expect(injected).toEqual([3, null])
})

it('provide function', () => {
new Vue({
template: `<child/>`,
data: {
a: 1,
b: 2
b: false
},
provide () {
return {
Expand All @@ -81,7 +81,7 @@ describe('Options provide/inject', () => {
}
}).$mount()

expect(injected).toEqual([1, 2])
expect(injected).toEqual([1, false])
})

it('inject with alias', () => {
Expand All @@ -99,7 +99,7 @@ describe('Options provide/inject', () => {
new Vue({
template: `<child/>`,
provide: {
foo: 1,
foo: false,
bar: 2
},
components: {
Expand All @@ -112,7 +112,7 @@ describe('Options provide/inject', () => {
}
}).$mount()

expect(injected).toEqual([1, 2])
expect(injected).toEqual([false, 2])
})

it('self-inject', () => {
Expand Down