Home / Function/ mergeDataOrFn() — vue Function Reference

mergeDataOrFn() — vue Function Reference

Architecture documentation for the mergeDataOrFn() function in options.ts from the vue codebase.

Function typescript VueCore Observer calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  86004998_27f2_db20_3ae5_d1baa8df7968["mergeDataOrFn()"]
  395cc6b0_6f88_f1b1_f5dd_8cdf5c229777["options.ts"]
  86004998_27f2_db20_3ae5_d1baa8df7968 -->|defined in| 395cc6b0_6f88_f1b1_f5dd_8cdf5c229777
  400da704_fbee_8793_f946_5579c4ca50dd["strats()"]
  400da704_fbee_8793_f946_5579c4ca50dd -->|calls| 86004998_27f2_db20_3ae5_d1baa8df7968
  a46cd6c3_9d19_f5e0_7752_7009a1d4a572["mergeData()"]
  86004998_27f2_db20_3ae5_d1baa8df7968 -->|calls| a46cd6c3_9d19_f5e0_7752_7009a1d4a572
  style 86004998_27f2_db20_3ae5_d1baa8df7968 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/util/options.ts lines 86–126

export function mergeDataOrFn(
  parentVal: any,
  childVal: any,
  vm?: Component
): Function | null {
  if (!vm) {
    // in a Vue.extend merge, both should be functions
    if (!childVal) {
      return parentVal
    }
    if (!parentVal) {
      return childVal
    }
    // when parentVal & childVal are both present,
    // we need to return a function that returns the
    // merged result of both functions... no need to
    // check if parentVal is a function here because
    // it has to be a function to pass previous merges.
    return function mergedDataFn() {
      return mergeData(
        isFunction(childVal) ? childVal.call(this, this) : childVal,
        isFunction(parentVal) ? parentVal.call(this, this) : parentVal
      )
    }
  } else {
    return function mergedInstanceDataFn() {
      // instance merge
      const instanceData = isFunction(childVal)
        ? childVal.call(vm, vm)
        : childVal
      const defaultData = isFunction(parentVal)
        ? parentVal.call(vm, vm)
        : parentVal
      if (instanceData) {
        return mergeData(instanceData, defaultData)
      } else {
        return defaultData
      }
    }
  }
}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does mergeDataOrFn() do?
mergeDataOrFn() is a function in the vue codebase, defined in src/core/util/options.ts.
Where is mergeDataOrFn() defined?
mergeDataOrFn() is defined in src/core/util/options.ts at line 86.
What does mergeDataOrFn() call?
mergeDataOrFn() calls 1 function(s): mergeData.
What calls mergeDataOrFn()?
mergeDataOrFn() is called by 1 function(s): strats.

Analyze Your Own Codebase

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

Try Supermodel Free