| 3665 | } |
| 3666 | |
| 3667 | function initInjections (vm) { |
| 3668 | var inject = vm.$options.inject; |
| 3669 | if (inject) { |
| 3670 | // inject is :any because flow is not smart enough to figure out cached |
| 3671 | // isArray here |
| 3672 | var isArray = Array.isArray(inject); |
| 3673 | var keys = isArray |
| 3674 | ? inject |
| 3675 | : hasSymbol |
| 3676 | ? Reflect.ownKeys(inject) |
| 3677 | : Object.keys(inject); |
| 3678 | |
| 3679 | var loop = function ( i ) { |
| 3680 | var key = keys[i]; |
| 3681 | var provideKey = isArray ? key : inject[key]; |
| 3682 | var source = vm; |
| 3683 | while (source) { |
| 3684 | if (source._provided && provideKey in source._provided) { |
| 3685 | /* istanbul ignore else */ |
| 3686 | { |
| 3687 | defineReactive$$1(vm, key, source._provided[provideKey], function () { |
| 3688 | warn( |
| 3689 | "Avoid mutating an injected value directly since the changes will be " + |
| 3690 | "overwritten whenever the provided component re-renders. " + |
| 3691 | "injection being mutated: \"" + key + "\"", |
| 3692 | vm |
| 3693 | ); |
| 3694 | }); |
| 3695 | } |
| 3696 | break |
| 3697 | } |
| 3698 | source = source.$parent; |
| 3699 | } |
| 3700 | }; |
| 3701 | |
| 3702 | for (var i = 0; i < keys.length; i++) loop( i ); |
| 3703 | } |
| 3704 | } |
| 3705 | |
| 3706 | /* */ |
| 3707 | |