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
  e3725706_6a2c_490a_e95e_84ad13fc4e05["mergeOptions()"]
  84cf3115_399b_21c2_480f_a8f2d39478c8["checkComponents()"]
  e3725706_6a2c_490a_e95e_84ad13fc4e05 -->|calls| 84cf3115_399b_21c2_480f_a8f2d39478c8
  5af21a52_5316_e857_22eb_dce69bb60268["isFunction()"]
  e3725706_6a2c_490a_e95e_84ad13fc4e05 -->|calls| 5af21a52_5316_e857_22eb_dce69bb60268
  4fb290a9_d45f_12dc_0184_c81185451355["normalizeProps()"]
  e3725706_6a2c_490a_e95e_84ad13fc4e05 -->|calls| 4fb290a9_d45f_12dc_0184_c81185451355
  10bf3c9d_b0e0_4358_120e_f3836c8d0a41["normalizeInject()"]
  e3725706_6a2c_490a_e95e_84ad13fc4e05 -->|calls| 10bf3c9d_b0e0_4358_120e_f3836c8d0a41
  3ec9558d_e7e3_33aa_ce50_79026db308c2["normalizeDirectives()"]
  e3725706_6a2c_490a_e95e_84ad13fc4e05 -->|calls| 3ec9558d_e7e3_33aa_ce50_79026db308c2
  f2fe9306_50d5_675e_2dfa_2c4d78443a49["hasOwn()"]
  e3725706_6a2c_490a_e95e_84ad13fc4e05 -->|calls| f2fe9306_50d5_675e_2dfa_2c4d78443a49
  style e3725706_6a2c_490a_e95e_84ad13fc4e05 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