wip: props default this compat

This commit is contained in:
Evan You
2021-04-06 11:08:21 -04:00
parent 65cc649559
commit d619a770a8
3 changed files with 28 additions and 3 deletions

View File

@@ -33,6 +33,7 @@ import {
import { isEmitListener } from './componentEmits'
import { InternalObjectKey } from './vnode'
import { AppContext } from './apiCreateApp'
import { createPropsDefaultThis } from './compat/props'
export type ComponentPropsOptions<P = Data> =
| ComponentObjectPropsOptions<P>
@@ -342,7 +343,10 @@ function resolvePropValue(
value = propsDefaults[key]
} else {
setCurrentInstance(instance)
value = propsDefaults[key] = defaultValue(props)
value = propsDefaults[key] =
__COMPAT__ && __DEV__
? defaultValue.call(createPropsDefaultThis(key), props)
: defaultValue(props)
setCurrentInstance(null)
}
} else {