MCPcopy
hub / github.com/vuejs/composition-api / mergeData

Function mergeData

src/install.ts:11–40  ·  view source on GitHub ↗

* Helper that recursively merges two data objects together.

(from: AnyObject, to: AnyObject)

Source from the content-addressed store, hash-verified

9 * Helper that recursively merges two data objects together.
10 */
11function mergeData(from: AnyObject, to: AnyObject): Object {
12 if (!from) return to
13 if (!to) return from
14
15 let key: any
16 let toVal: any
17 let fromVal: any
18
19 const keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from)
20
21 for (let i = 0; i < keys.length; i++) {
22 key = keys[i]
23 // in case the object is already observed...
24 if (key === '__ob__') continue
25 toVal = to[key]
26 fromVal = from[key]
27 if (!hasOwn(to, key)) {
28 to[key] = fromVal
29 } else if (
30 toVal !== fromVal &&
31 isPlainObject(toVal) &&
32 !isRef(toVal) &&
33 isPlainObject(fromVal) &&
34 !isRef(fromVal)
35 ) {
36 mergeData(fromVal, toVal)
37 }
38 }
39 return to
40}
41
42export function install(Vue: VueConstructor) {
43 if (isVueRegistered(Vue)) {

Callers 1

installFunction · 0.85

Calls 3

hasOwnFunction · 0.90
isPlainObjectFunction · 0.90
isRefFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…