Skip to content

Commit 30afa7a

Browse files
committed
fix when undefined is provided
1 parent 4cdb589 commit 30afa7a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/core/instance/inject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function resolveInject (inject: any, vm: Component): ?Object {
5757
}
5858
source = source.$parent
5959
}
60-
process.env.NODE_ENV !== 'production' && typeof result[key] === 'undefined' &&
60+
process.env.NODE_ENV !== 'production' && Object.keys(result).indexOf(key) < 0 &&
6161
warn(`Injection "${key}" not found`, vm)
6262
}
6363
return result

test/unit/features/options/inject.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,13 @@ describe('Options provide/inject', () => {
256256
const vm = new Vue({
257257
provide: {
258258
foo: 1,
259-
bar: false
259+
bar: false,
260+
baz: undefined
260261
}
261262
})
262263
new Vue({
263264
parent: vm,
264-
inject: ['foo', 'bar'],
265+
inject: ['foo', 'bar', 'baz'],
265266
created () {}
266267
})
267268
expect(`Injection "foo" not found`).not.toHaveBeenWarned()

0 commit comments

Comments
 (0)