Home / Function/ getPropDefaultValue() — vue Function Reference

getPropDefaultValue() — vue Function Reference

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

Function typescript CoreRuntime Observer calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  a06153e2_673f_da2d_1fcd_fd4c7ab29577["getPropDefaultValue()"]
  e8576a88_2e85_86ff_b2f9_bbbb6de70a51["props.ts"]
  a06153e2_673f_da2d_1fcd_fd4c7ab29577 -->|defined in| e8576a88_2e85_86ff_b2f9_bbbb6de70a51
  b943403b_6390_a1db_4eec_d4fea1238518["validateProp()"]
  b943403b_6390_a1db_4eec_d4fea1238518 -->|calls| a06153e2_673f_da2d_1fcd_fd4c7ab29577
  e8b22500_20a5_2e19_4c79_386004841499["warn()"]
  a06153e2_673f_da2d_1fcd_fd4c7ab29577 -->|calls| e8b22500_20a5_2e19_4c79_386004841499
  f5fda3f6_b160_81e4_ce76_ab6eb1b1fa39["getType()"]
  a06153e2_673f_da2d_1fcd_fd4c7ab29577 -->|calls| f5fda3f6_b160_81e4_ce76_ab6eb1b1fa39
  style a06153e2_673f_da2d_1fcd_fd4c7ab29577 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, defined in src/core/util/props.ts.
Where is getPropDefaultValue() defined?
getPropDefaultValue() is defined in src/core/util/props.ts at line 64.
What does getPropDefaultValue() call?
getPropDefaultValue() calls 2 function(s): getType, 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