options.ts (vue-2.7.13) | : | options.ts (vue-2.7.14) | ||
---|---|---|---|---|
skipping to change at line 54 | skipping to change at line 54 | |||
} | } | |||
return defaultStrat(parent, child) | return defaultStrat(parent, child) | |||
} | } | |||
} | } | |||
/** | /** | |||
* Helper that recursively merges two data objects together. | * Helper that recursively merges two data objects together. | |||
*/ | */ | |||
function mergeData( | function mergeData( | |||
to: Record<string | symbol, any>, | to: Record<string | symbol, any>, | |||
from: Record<string | symbol, any> | null | from: Record<string | symbol, any> | null, | |||
recursive = true | ||||
): Record<PropertyKey, any> { | ): Record<PropertyKey, any> { | |||
if (!from) return to | if (!from) return to | |||
let key, toVal, fromVal | let key, toVal, fromVal | |||
const keys = hasSymbol | const keys = hasSymbol | |||
? (Reflect.ownKeys(from) as string[]) | ? (Reflect.ownKeys(from) as string[]) | |||
: Object.keys(from) | : Object.keys(from) | |||
for (let i = 0; i < keys.length; i++) { | for (let i = 0; i < keys.length; i++) { | |||
key = keys[i] | key = keys[i] | |||
// in case the object is already observed... | // in case the object is already observed... | |||
if (key === '__ob__') continue | if (key === '__ob__') continue | |||
toVal = to[key] | toVal = to[key] | |||
fromVal = from[key] | fromVal = from[key] | |||
if (!hasOwn(to, key)) { | if (!recursive || !hasOwn(to, key)) { | |||
set(to, key, fromVal) | set(to, key, fromVal) | |||
} else if ( | } else if ( | |||
toVal !== fromVal && | toVal !== fromVal && | |||
isPlainObject(toVal) && | isPlainObject(toVal) && | |||
isPlainObject(fromVal) | isPlainObject(fromVal) | |||
) { | ) { | |||
mergeData(toVal, fromVal) | mergeData(toVal, fromVal) | |||
} | } | |||
} | } | |||
return to | return to | |||
skipping to change at line 265 | skipping to change at line 266 | |||
): Object | null { | ): Object | null { | |||
if (childVal && __DEV__) { | if (childVal && __DEV__) { | |||
assertObjectType(key, childVal, vm) | assertObjectType(key, childVal, vm) | |||
} | } | |||
if (!parentVal) return childVal | if (!parentVal) return childVal | |||
const ret = Object.create(null) | const ret = Object.create(null) | |||
extend(ret, parentVal) | extend(ret, parentVal) | |||
if (childVal) extend(ret, childVal) | if (childVal) extend(ret, childVal) | |||
return ret | return ret | |||
} | } | |||
strats.provide = mergeDataOrFn | ||||
strats.provide = function (parentVal: Object | null, childVal: Object | null) { | ||||
if (!parentVal) return childVal | ||||
return function () { | ||||
const ret = Object.create(null) | ||||
mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal) | ||||
if (childVal) { | ||||
mergeData( | ||||
ret, | ||||
isFunction(childVal) ? childVal.call(this) : childVal, | ||||
false // non-recursive | ||||
) | ||||
} | ||||
return ret | ||||
} | ||||
} | ||||
/** | /** | |||
* Default strategy. | * Default strategy. | |||
*/ | */ | |||
const defaultStrat = function (parentVal: any, childVal: any): any { | const defaultStrat = function (parentVal: any, childVal: any): any { | |||
return childVal === undefined ? parentVal : childVal | return childVal === undefined ? parentVal : childVal | |||
} | } | |||
/** | /** | |||
* Validate component names | * Validate component names | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 19 lines changed or added |