diff --git a/src/core/instance/inject.js b/src/core/instance/inject.js
index 2b1fd7f0274..0c55b42a629 100644
--- a/src/core/instance/inject.js
+++ b/src/core/instance/inject.js
@@ -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
}
diff --git a/test/unit/features/options/inject.spec.js b/test/unit/features/options/inject.spec.js
index a80734bca79..500d3aed607 100644
--- a/test/unit/features/options/inject.spec.js
+++ b/test/unit/features/options/inject.spec.js
@@ -20,7 +20,7 @@ describe('Options provide/inject', () => {
template: ``,
provide: {
foo: 1,
- bar: 2
+ bar: false
},
components: {
child: {
@@ -32,7 +32,7 @@ describe('Options provide/inject', () => {
}
}).$mount()
- expect(injected).toEqual([1, 2])
+ expect(injected).toEqual([1, false])
})
it('should use closest parent', () => {
@@ -40,7 +40,7 @@ describe('Options provide/inject', () => {
template: ``,
provide: {
foo: 1,
- bar: 2
+ bar: null
},
components: {
child: {
@@ -55,7 +55,7 @@ describe('Options provide/inject', () => {
}
}).$mount()
- expect(injected).toEqual([3, 2])
+ expect(injected).toEqual([3, null])
})
it('provide function', () => {
@@ -63,7 +63,7 @@ describe('Options provide/inject', () => {
template: ``,
data: {
a: 1,
- b: 2
+ b: false
},
provide () {
return {
@@ -81,7 +81,7 @@ describe('Options provide/inject', () => {
}
}).$mount()
- expect(injected).toEqual([1, 2])
+ expect(injected).toEqual([1, false])
})
it('inject with alias', () => {
@@ -99,7 +99,7 @@ describe('Options provide/inject', () => {
new Vue({
template: ``,
provide: {
- foo: 1,
+ foo: false,
bar: 2
},
components: {
@@ -112,7 +112,7 @@ describe('Options provide/inject', () => {
}
}).$mount()
- expect(injected).toEqual([1, 2])
+ expect(injected).toEqual([false, 2])
})
it('self-inject', () => {