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

16 lines
479 B
TypeScript
Raw Normal View History

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