diff --git a/src/core/instance/inject.js b/src/core/instance/inject.js index 0afd3c81ffc..ecb3e0846a9 100644 --- a/src/core/instance/inject.js +++ b/src/core/instance/inject.js @@ -41,7 +41,9 @@ export function resolveInject (inject: any, vm: Component): ?Object { // inject is :any because flow is not smart enough to figure out cached const result = Object.create(null) const keys = hasSymbol - ? Reflect.ownKeys(inject) + ? Reflect.ownKeys(inject).filter(key => { + return Object.getOwnPropertyDescriptor(inject, key).enumerable + }) : Object.keys(inject) for (let i = 0; i < keys.length; i++) { diff --git a/test/unit/features/options/inject.spec.js b/test/unit/features/options/inject.spec.js index 3641a56f61c..86e3ada5736 100644 --- a/test/unit/features/options/inject.spec.js +++ b/test/unit/features/options/inject.spec.js @@ -362,7 +362,15 @@ describe('Options provide/inject', () => { expect(`Injection "baz" not found`).not.toHaveBeenWarned() }) - // GitHub issue #6008 + it('should not warn when injection key which is not provided is not enumerable', () => { + const parent = new Vue({ provide: { foo: 1 }}) + const inject = { foo: 'foo' } + Object.defineProperty(inject, '__ob__', { enumerable: false, value: '__ob__' }) + new Vue({ parent, inject }) + expect(`Injection "__ob__" not found`).not.toHaveBeenWarned() + }) + + // Github issue #6008 it('should merge provide from mixins (objects)', () => { const mixinA = { provide: { foo: 'foo' }} const mixinB = { provide: { bar: 'bar' }}