Home / Function/ mergeOptions() — vue Function Reference

mergeOptions() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  892cde94_b9ea_1f44_2d22_879e0dc87e80["mergeOptions()"]
  f9a04a4a_086c_f4c9_b94b_e0ee7fbc01f3["checkComponents()"]
  892cde94_b9ea_1f44_2d22_879e0dc87e80 -->|calls| f9a04a4a_086c_f4c9_b94b_e0ee7fbc01f3
  b6885901_8acd_8c4a_af15_cbd768bcd57b["isFunction()"]
  892cde94_b9ea_1f44_2d22_879e0dc87e80 -->|calls| b6885901_8acd_8c4a_af15_cbd768bcd57b
  bf540967_af11_4bc9_3b8c_e01a05be85df["normalizeProps()"]
  892cde94_b9ea_1f44_2d22_879e0dc87e80 -->|calls| bf540967_af11_4bc9_3b8c_e01a05be85df
  badf6762_f5f3_e870_8c0c_c168b9ecca0d["normalizeInject()"]
  892cde94_b9ea_1f44_2d22_879e0dc87e80 -->|calls| badf6762_f5f3_e870_8c0c_c168b9ecca0d
  8d79e2ef_e7a6_e32f_d130_4dd5dc21af4a["normalizeDirectives()"]
  892cde94_b9ea_1f44_2d22_879e0dc87e80 -->|calls| 8d79e2ef_e7a6_e32f_d130_4dd5dc21af4a
  48552ac3_589d_0990_1979_1bd455665b33["hasOwn()"]
  892cde94_b9ea_1f44_2d22_879e0dc87e80 -->|calls| 48552ac3_589d_0990_1979_1bd455665b33
  style 892cde94_b9ea_1f44_2d22_879e0dc87e80 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/util/options.ts lines 411–459

export function mergeOptions(
  parent: Record<string, any>,
  child: Record<string, any>,
  vm?: Component | null
): ComponentOptions {
  if (__DEV__) {
    checkComponents(child)
  }

  if (isFunction(child)) {
    // @ts-expect-error
    child = child.options
  }

  normalizeProps(child, vm)
  normalizeInject(child, vm)
  normalizeDirectives(child)

  // Apply extends and mixins on the child options,
  // but only if it is a raw options object that isn't
  // the result of another mergeOptions call.
  // Only merged options has the _base property.
  if (!child._base) {
    if (child.extends) {
      parent = mergeOptions(parent, child.extends, vm)
    }
    if (child.mixins) {
      for (let i = 0, l = child.mixins.length; i < l; i++) {
        parent = mergeOptions(parent, child.mixins[i], vm)
      }
    }
  }

  const options: ComponentOptions = {} as any
  let key
  for (key in parent) {
    mergeField(key)
  }
  for (key in child) {
    if (!hasOwn(parent, key)) {
      mergeField(key)
    }
  }
  function mergeField(key: any) {
    const strat = strats[key] || defaultStrat
    options[key] = strat(parent[key], child[key], vm, key)
  }
  return options
}

Domain

Subdomains

Frequently Asked Questions

What does mergeOptions() do?
mergeOptions() is a function in the vue codebase.
What does mergeOptions() call?
mergeOptions() calls 6 function(s): checkComponents, hasOwn, isFunction, normalizeDirectives, normalizeInject, normalizeProps.

Analyze Your Own Codebase

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

Try Supermodel Free