( injectOptions: ComponentInjectOptions, ctx: any, checkDuplicateProperties = NOOP as any, )
| 792 | } |
| 793 | |
| 794 | export function resolveInjections( |
| 795 | injectOptions: ComponentInjectOptions, |
| 796 | ctx: any, |
| 797 | checkDuplicateProperties = NOOP as any, |
| 798 | ): void { |
| 799 | if (isArray(injectOptions)) { |
| 800 | injectOptions = normalizeInject(injectOptions)! |
| 801 | } |
| 802 | for (const key in injectOptions) { |
| 803 | const opt = injectOptions[key] |
| 804 | let injected: unknown |
| 805 | if (isObject(opt)) { |
| 806 | if ('default' in opt) { |
| 807 | injected = inject( |
| 808 | opt.from || key, |
| 809 | opt.default, |
| 810 | true /* treat default function as factory */, |
| 811 | ) |
| 812 | } else { |
| 813 | injected = inject(opt.from || key) |
| 814 | } |
| 815 | } else { |
| 816 | injected = inject(opt) |
| 817 | } |
| 818 | if (isRef(injected)) { |
| 819 | // unwrap injected refs (ref #4196) |
| 820 | Object.defineProperty(ctx, key, { |
| 821 | enumerable: true, |
| 822 | configurable: true, |
| 823 | get: () => (injected as Ref).value, |
| 824 | set: v => ((injected as Ref).value = v), |
| 825 | }) |
| 826 | } else { |
| 827 | ctx[key] = injected |
| 828 | } |
| 829 | if (__DEV__) { |
| 830 | checkDuplicateProperties!(OptionTypes.INJECT, key) |
| 831 | } |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | function callHook( |
| 836 | hook: Function, |
no test coverage detected