2021-04-06 13:31:47 +00:00
|
|
|
import { isPlainObject } from '@vue/shared'
|
2021-04-09 22:52:14 +00:00
|
|
|
import { ComponentInternalInstance } from '../component'
|
2021-04-06 13:31:47 +00:00
|
|
|
import { DeprecationTypes, warnDeprecation } from './deprecations'
|
|
|
|
|
2021-04-09 22:52:14 +00:00
|
|
|
export function deepMergeData(
|
|
|
|
to: any,
|
|
|
|
from: any,
|
|
|
|
instance: ComponentInternalInstance
|
|
|
|
) {
|
2021-04-06 13:31:47 +00:00
|
|
|
for (const key in from) {
|
|
|
|
const toVal = to[key]
|
|
|
|
const fromVal = from[key]
|
|
|
|
if (key in to && isPlainObject(toVal) && isPlainObject(fromVal)) {
|
2021-04-09 22:52:14 +00:00
|
|
|
__DEV__ &&
|
|
|
|
warnDeprecation(DeprecationTypes.OPTIONS_DATA_MERGE, instance, key)
|
|
|
|
deepMergeData(toVal, fromVal, instance)
|
2021-04-06 13:31:47 +00:00
|
|
|
} else {
|
|
|
|
to[key] = fromVal
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|