-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runtime-core): align option merge behavior with Vue 2
- Loading branch information
Showing
9 changed files
with
435 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,16 @@ | ||
import { isFunction, isPlainObject } from '@vue/shared' | ||
import { ComponentInternalInstance } from '../component' | ||
import { ComponentPublicInstance } from '../componentPublicInstance' | ||
import { isPlainObject } from '@vue/shared' | ||
import { DeprecationTypes, warnDeprecation } from './compatConfig' | ||
|
||
export function deepMergeData( | ||
to: any, | ||
from: any, | ||
instance: ComponentInternalInstance | ||
) { | ||
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, instance, key) | ||
deepMergeData(toVal, fromVal, instance) | ||
__DEV__ && warnDeprecation(DeprecationTypes.OPTIONS_DATA_MERGE, null, key) | ||
deepMergeData(toVal, fromVal) | ||
} else { | ||
to[key] = fromVal | ||
} | ||
} | ||
return to | ||
} | ||
|
||
export function mergeDataOption(to: any, from: any) { | ||
if (!from) { | ||
return to | ||
} | ||
if (!to) { | ||
return from | ||
} | ||
return function mergedDataFn(this: ComponentPublicInstance) { | ||
return deepMergeData( | ||
isFunction(to) ? to.call(this, this) : to, | ||
isFunction(from) ? from.call(this, this) : from, | ||
this.$ | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.