MCPcopy Index your code
hub / github.com/keepfool/vue-tutorials / getPropDefaultValue

Function getPropDefaultValue

06.Router/basic/js/vue.js:6224–6238  ·  view source on GitHub ↗

* Get the default value of a prop. * * @param {Vue} vm * @param {Object} prop * @return {*}

(vm, prop)

Source from the content-addressed store, hash-verified

6222 */
6223
6224 function getPropDefaultValue(vm, prop) {
6225 // no default, return undefined
6226 var options = prop.options;
6227 if (!hasOwn(options, 'default')) {
6228 // absent boolean value defaults to false
6229 return options.type === Boolean ? false : undefined;
6230 }
6231 var def = options['default'];
6232 // warn against non-factory defaults for Object & Array
6233 if (isObject(def)) {
6234 'development' !== 'production' && warn('Invalid default value for prop "' + prop.name + '": ' + 'Props with type Object/Array must use a factory function ' + 'to return the default value.', vm);
6235 }
6236 // call factory function for non-Function types
6237 return typeof def === 'function' && options.type !== Function ? def.call(vm) : def;
6238 }
6239
6240 /**
6241 * Assert whether a prop is valid.

Callers 1

processPropValueFunction · 0.70

Calls 3

hasOwnFunction · 0.70
isObjectFunction · 0.70
warnFunction · 0.70

Tested by

no test coverage detected