MCPcopy Create free account
hub / github.com/TruthHun/BookStack / getPropDefaultValue

Function getPropDefaultValue

static/vuejs/vue.esm.js:1306–1333  ·  view source on GitHub ↗

* Get the default value of a prop.

(vm, prop, key)

Source from the content-addressed store, hash-verified

1304 * Get the default value of a prop.
1305 */
1306function getPropDefaultValue (vm, prop, key) {
1307 // no default, return undefined
1308 if (!hasOwn(prop, 'default')) {
1309 return undefined
1310 }
1311 var def = prop.default;
1312 // warn against non-factory defaults for Object & Array
1313 if (process.env.NODE_ENV !== 'production' && isObject(def)) {
1314 warn(
1315 'Invalid default value for prop "' + key + '": ' +
1316 'Props with type Object/Array must use a factory function ' +
1317 'to return the default value.',
1318 vm
1319 );
1320 }
1321 // the raw prop value was also undefined from previous render,
1322 // return previous default value to avoid unnecessary watcher trigger
1323 if (vm && vm.$options.propsData &&
1324 vm.$options.propsData[key] === undefined &&
1325 vm._props[key] !== undefined) {
1326 return vm._props[key]
1327 }
1328 // call factory function for non-Function types
1329 // a value is Function if its prototype is function even across different execution context
1330 return typeof def === 'function' && getType(prop.type) !== 'Function'
1331 ? def.call(vm)
1332 : def
1333}
1334
1335/**
1336 * Assert whether a prop is valid.

Callers 1

validatePropFunction · 0.70

Calls 4

hasOwnFunction · 0.70
isObjectFunction · 0.70
getTypeFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected