feat(runtime-core): support config.optionMergeStrategies

Note the behavior is different from Vue 2:
- merge strategies no longer apply to built-in options.
- the default value is now an empty object and no longer exposes merge
  strategies for built-in options.
This commit is contained in:
Evan You
2020-03-24 11:59:00 -04:00
parent 123738727a
commit 528621ba41
5 changed files with 82 additions and 11 deletions

View File

@@ -36,11 +36,21 @@ export interface App<HostElement = any> {
_context: AppContext
}
export type OptionMergeFunction = (
to: unknown,
from: unknown,
instance: any,
key: string
) => any
export interface AppConfig {
// @private
readonly isNativeTag?: (tag: string) => boolean
devtools: boolean
performance: boolean
readonly isNativeTag?: (tag: string) => boolean
isCustomElement?: (tag: string) => boolean
optionMergeStrategies: Record<string, OptionMergeFunction>
isCustomElement: (tag: string) => boolean
errorHandler?: (
err: unknown,
instance: ComponentPublicInstance | null,
@@ -73,9 +83,10 @@ export type Plugin =
export function createAppContext(): AppContext {
return {
config: {
isNativeTag: NO,
devtools: true,
performance: false,
isNativeTag: NO,
optionMergeStrategies: {},
isCustomElement: NO,
errorHandler: undefined,
warnHandler: undefined