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

@@ -66,7 +66,8 @@ import { VNodeChild } from './vnode'
import { callWithAsyncErrorHandling } from './errorHandling'
import { UnionToIntersection } from './helpers/typeUtils'
import { deepMergeData } from './compat/data'
import { DeprecationTypes, warnDeprecation } from './compat/deprecations'
import { DeprecationTypes } from './compat/deprecations'
import { isCompatEnabled, softAssertCompatEnabled } from './compat/compatConfig'
/**
* Interface for declaring custom options.
@@ -805,12 +806,16 @@ export function applyOptions(
}
if (__COMPAT__) {
if (beforeDestroy) {
__DEV__ && warnDeprecation(DeprecationTypes.OPTIONS_BEFORE_DESTROY)
if (
beforeDestroy &&
softAssertCompatEnabled(DeprecationTypes.OPTIONS_BEFORE_DESTROY)
) {
onBeforeUnmount(beforeDestroy.bind(publicThis))
}
if (destroyed) {
__DEV__ && warnDeprecation(DeprecationTypes.OPTIONS_DESTROYED)
if (
destroyed &&
softAssertCompatEnabled(DeprecationTypes.OPTIONS_DESTROYED)
) {
onUnmounted(destroyed.bind(publicThis))
}
}
@@ -911,7 +916,7 @@ function resolveData(
instance.data = reactive(data)
} else {
// existing data: this is a mixin or extends.
if (__COMPAT__) {
if (__COMPAT__ && isCompatEnabled(DeprecationTypes.OPTIONS_DATA_MERGE)) {
deepMergeData(instance.data, data)
} else {
extend(instance.data, data)