MCPcopy
hub / github.com/fanmingming/live / getPropDefaultValue

Function getPropDefaultValue

m3u8/vue.js:1648–1676  ·  view source on GitHub ↗

* Get the default value of a prop.

(vm, prop, key)

Source from the content-addressed store, hash-verified

1646 * Get the default value of a prop.
1647 */
1648 function getPropDefaultValue (vm, prop, key) {
1649 // no default, return undefined
1650 if (!hasOwn(prop, 'default')) {
1651 return undefined
1652 }
1653 var def = prop.default;
1654 // warn against non-factory defaults for Object & Array
1655 if (isObject(def)) {
1656 warn(
1657 'Invalid default value for prop "' + key + '": ' +
1658 'Props with type Object/Array must use a factory function ' +
1659 'to return the default value.',
1660 vm
1661 );
1662 }
1663 // the raw prop value was also undefined from previous render,
1664 // return previous default value to avoid unnecessary watcher trigger
1665 if (vm && vm.$options.propsData &&
1666 vm.$options.propsData[key] === undefined &&
1667 vm._props[key] !== undefined
1668 ) {
1669 return vm._props[key]
1670 }
1671 // call factory function for non-Function types
1672 // a value is Function if its prototype is function even across different execution context
1673 return typeof def === 'function' && getType(prop.type) !== 'Function'
1674 ? def.call(vm)
1675 : def
1676 }
1677
1678 /**
1679 * Assert whether a prop is valid.

Callers 1

validatePropFunction · 0.85

Calls 4

hasOwnFunction · 0.85
isObjectFunction · 0.85
warnFunction · 0.85
getTypeFunction · 0.85

Tested by

no test coverage detected