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