Home / Function/ getPropDefaultValue() — vue Function Reference

getPropDefaultValue() — vue Function Reference

Architecture documentation for the getPropDefaultValue() function in props.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  d405b246_79c5_0fda_f20d_75ebd8bfe36b["getPropDefaultValue()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab["validateProp()"]
  50f52114_04b8_bc98_a41e_bc26a88ea2ab -->|calls| d405b246_79c5_0fda_f20d_75ebd8bfe36b
  48552ac3_589d_0990_1979_1bd455665b33["hasOwn()"]
  d405b246_79c5_0fda_f20d_75ebd8bfe36b -->|calls| 48552ac3_589d_0990_1979_1bd455665b33
  3d975ef8_6070_36a5_82f8_9180576e2ca1["isObject()"]
  d405b246_79c5_0fda_f20d_75ebd8bfe36b -->|calls| 3d975ef8_6070_36a5_82f8_9180576e2ca1
  a8c8f192_fd2d_dbe3_46ed_dd8fabebc429["warn()"]
  d405b246_79c5_0fda_f20d_75ebd8bfe36b -->|calls| a8c8f192_fd2d_dbe3_46ed_dd8fabebc429
  b6885901_8acd_8c4a_af15_cbd768bcd57b["isFunction()"]
  d405b246_79c5_0fda_f20d_75ebd8bfe36b -->|calls| b6885901_8acd_8c4a_af15_cbd768bcd57b
  e637891d_285c_15ea_8a69_13f420f671c0["getType()"]
  d405b246_79c5_0fda_f20d_75ebd8bfe36b -->|calls| e637891d_285c_15ea_8a69_13f420f671c0
  style d405b246_79c5_0fda_f20d_75ebd8bfe36b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/util/props.ts lines 64–100

function getPropDefaultValue(
  vm: Component | undefined,
  prop: PropOptions,
  key: string
): any {
  // no default, return undefined
  if (!hasOwn(prop, 'default')) {
    return undefined
  }
  const def = prop.default
  // warn against non-factory defaults for Object & Array
  if (__DEV__ && isObject(def)) {
    warn(
      'Invalid default value for prop "' +
        key +
        '": ' +
        'Props with type Object/Array must use a factory function ' +
        'to return the default value.',
      vm
    )
  }
  // the raw prop value was also undefined from previous render,
  // return previous default value to avoid unnecessary watcher trigger
  if (
    vm &&
    vm.$options.propsData &&
    vm.$options.propsData[key] === undefined &&
    vm._props[key] !== undefined
  ) {
    return vm._props[key]
  }
  // call factory function for non-Function types
  // a value is Function if its prototype is function even across different execution context
  return isFunction(def) && getType(prop.type) !== 'Function'
    ? def.call(vm)
    : def
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getPropDefaultValue() do?
getPropDefaultValue() is a function in the vue codebase.
What does getPropDefaultValue() call?
getPropDefaultValue() calls 5 function(s): getType, hasOwn, isFunction, isObject, warn.
What calls getPropDefaultValue()?
getPropDefaultValue() is called by 1 function(s): validateProp.

Analyze Your Own Codebase

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

Try Supermodel Free