|
|
@@ -47,7 +47,7 @@ export function validateProp (
|
|
|
/**
|
|
|
* Get the default value of a prop.
|
|
|
*/
|
|
|
-function getPropDefaultValue (vm: ?Component, prop: PropOptions, name: string): any {
|
|
|
+function getPropDefaultValue (vm: ?Component, prop: PropOptions, key: string): any {
|
|
|
// no default, return undefined
|
|
|
if (!hasOwn(prop, 'default')) {
|
|
|
return undefined
|
|
|
@@ -56,12 +56,19 @@ function getPropDefaultValue (vm: ?Component, prop: PropOptions, name: string):
|
|
|
// warn against non-factory defaults for Object & Array
|
|
|
if (isObject(def)) {
|
|
|
process.env.NODE_ENV !== 'production' && warn(
|
|
|
- 'Invalid default value for prop "' + name + '": ' +
|
|
|
+ '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[key] !== undefined) {
|
|
|
+ return vm[key]
|
|
|
+ }
|
|
|
// call factory function for non-Function types
|
|
|
return typeof def === 'function' && prop.type !== Function
|
|
|
? def.call(vm)
|