vue3-yuanma/packages/runtime-core/src/compat/data.ts

22 lines
609 B
TypeScript
Raw Normal View History

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'
import { DeprecationTypes, warnDeprecation } from './compatConfig'
2021-04-06 13:31:47 +00:00
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
}
}
}