wip: apply compat enabled flags to currently implemented features

This commit is contained in:
Evan You
2021-04-07 15:38:04 -04:00
parent 208bef5d97
commit 1c2c77eb9f
13 changed files with 189 additions and 126 deletions

View File

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