Home / Function/ mergeDataOrFn() — vue Function Reference

mergeDataOrFn() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  4f49ac70_a342_d58b_3b5b_116092765886["mergeDataOrFn()"]
  5c734a8f_efba_819c_28fc_f56bfd6b701f["options.ts"]
  4f49ac70_a342_d58b_3b5b_116092765886 -->|defined in| 5c734a8f_efba_819c_28fc_f56bfd6b701f
  b1cf23c1_b9b6_663a_5e34_0711ca6cb0b6["strats()"]
  b1cf23c1_b9b6_663a_5e34_0711ca6cb0b6 -->|calls| 4f49ac70_a342_d58b_3b5b_116092765886
  9efe5186_8c34_d7d4_88d0_e9a686898b28["mergeData()"]
  4f49ac70_a342_d58b_3b5b_116092765886 -->|calls| 9efe5186_8c34_d7d4_88d0_e9a686898b28
  style 4f49ac70_a342_d58b_3b5b_116092765886 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