Home / Function/ resolveInject() — vue Function Reference

resolveInject() — vue Function Reference

Architecture documentation for the resolveInject() function in inject.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  38a042a8_e008_9381_562a_4c9fe664057e["resolveInject()"]
  4ac7e661_4a8f_08cb_4f7e_e4704e6ee6bd["inject.ts"]
  38a042a8_e008_9381_562a_4c9fe664057e -->|defined in| 4ac7e661_4a8f_08cb_4f7e_e4704e6ee6bd
  3204874f_4db2_0342_a8fc_5a37bc2a2832["initInjections()"]
  3204874f_4db2_0342_a8fc_5a37bc2a2832 -->|calls| 38a042a8_e008_9381_562a_4c9fe664057e
  c5286b65_3542_0b12_cbd4_8f0583f72f9a["FunctionalRenderContext()"]
  c5286b65_3542_0b12_cbd4_8f0583f72f9a -->|calls| 38a042a8_e008_9381_562a_4c9fe664057e
  style 38a042a8_e008_9381_562a_4c9fe664057e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/instance/inject.ts lines 53–80

export function resolveInject(
  inject: any,
  vm: Component
): Record<string, any> | undefined | null {
  if (inject) {
    // inject is :any because flow is not smart enough to figure out cached
    const result = Object.create(null)
    const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject)

    for (let i = 0; i < keys.length; i++) {
      const key = keys[i]
      // #6574 in case the inject object is observed...
      if (key === '__ob__') continue
      const provideKey = inject[key].from
      if (provideKey in vm._provided) {
        result[key] = vm._provided[provideKey]
      } else if ('default' in inject[key]) {
        const provideDefault = inject[key].default
        result[key] = isFunction(provideDefault)
          ? provideDefault.call(vm)
          : provideDefault
      } else if (__DEV__) {
        warn(`Injection "${key as string}" not found`, vm)
      }
    }
    return result
  }
}

Domain

Subdomains

Frequently Asked Questions

What does resolveInject() do?
resolveInject() is a function in the vue codebase, defined in src/core/instance/inject.ts.
Where is resolveInject() defined?
resolveInject() is defined in src/core/instance/inject.ts at line 53.
What calls resolveInject()?
resolveInject() is called by 2 function(s): FunctionalRenderContext, initInjections.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free