|
|
@@ -139,6 +139,9 @@ export function initProps(
|
|
|
const props: Data = {}
|
|
|
const attrs: Data = {}
|
|
|
def(attrs, InternalObjectKey, 1)
|
|
|
+
|
|
|
+ instance.propsDefaults = Object.create(null)
|
|
|
+
|
|
|
setFullProps(instance, rawProps, props, attrs)
|
|
|
// validation
|
|
|
if (__DEV__) {
|
|
|
@@ -326,9 +329,14 @@ function resolvePropValue(
|
|
|
if (hasDefault && value === undefined) {
|
|
|
const defaultValue = opt.default
|
|
|
if (opt.type !== Function && isFunction(defaultValue)) {
|
|
|
- setCurrentInstance(instance)
|
|
|
- value = defaultValue(props)
|
|
|
- setCurrentInstance(null)
|
|
|
+ const { propsDefaults } = instance
|
|
|
+ if (key in propsDefaults) {
|
|
|
+ value = propsDefaults[key]
|
|
|
+ } else {
|
|
|
+ setCurrentInstance(instance)
|
|
|
+ value = propsDefaults[key] = defaultValue(props)
|
|
|
+ setCurrentInstance(null)
|
|
|
+ }
|
|
|
} else {
|
|
|
value = defaultValue
|
|
|
}
|