fix(runtime-core): fix resolving assets from mixins and extends

fix #1963
This commit is contained in:
Evan You
2020-08-26 18:09:54 -04:00
parent bc64c60c7e
commit 0cb7f7f880
4 changed files with 107 additions and 3 deletions

View File

@@ -384,6 +384,9 @@ export function applyOptions(
watch: watchOptions,
provide: provideOptions,
inject: injectOptions,
// assets
components,
directives,
// lifecycle
beforeMount,
mounted,
@@ -568,6 +571,32 @@ export function applyOptions(
}
}
// asset options.
// To reduce memory usage, only components with mixins or extends will have
// resolved asset registry attached to instance.
if (asMixin) {
if (components) {
extend(
instance.components ||
(instance.components = extend(
{},
(instance.type as ComponentOptions).components
) as Record<string, ConcreteComponent>),
components
)
}
if (directives) {
extend(
instance.directives ||
(instance.directives = extend(
{},
(instance.type as ComponentOptions).directives
)),
directives
)
}
}
// lifecycle options
if (!asMixin) {
callSyncHook('created', options, publicThis, globalMixins)