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

Function getPropDefaultValue

static/vuejs/vue.runtime.js:1308–1335  ·  view source on GitHub ↗

* Get the default value of a prop.

(vm, prop, key)

Source from the content-addressed store, hash-verified

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