Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): fix resolving inheritAttrs from mixins #3742

Merged
merged 4 commits into from
May 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,6 @@ export function applyOptions(
const ctx = instance.ctx
const globalMixins = instance.appContext.mixins

if (asMixin && render && instance.render === NOOP) {
instance.render = render as InternalRenderFunction
}

// applyOptions is called non-as-mixin once per instance
if (!asMixin) {
shouldCacheAccess = false
Expand Down Expand Up @@ -745,19 +741,6 @@ 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) {
resolveInstanceAssets(instance, options, COMPONENTS)
resolveInstanceAssets(instance, options, DIRECTIVES)
if (__COMPAT__ && isCompatEnabled(DeprecationTypes.FILTERS, instance)) {
resolveInstanceAssets(instance, options, FILTERS)
}

if (inheritAttrs !== undefined) instance.inheritAttrs = inheritAttrs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: should only set this if the base component doesn't have the option (which should have highest priority)

}

// lifecycle options
if (!asMixin) {
callSyncHook(
Expand Down Expand Up @@ -831,6 +814,27 @@ export function applyOptions(
warn(`The \`expose\` option is ignored when used in mixins.`)
}
}

// options that are handled when creating the instance but also need to be
// applied from mixins
if (asMixin) {
if (render && instance.render === NOOP) {
instance.render = render as InternalRenderFunction
}

if (inheritAttrs != null && instance.type.inheritAttrs == null) {
instance.inheritAttrs = inheritAttrs
}

// asset options.
// To reduce memory usage, only components with mixins or extends will have
// resolved asset registry attached to instance.
resolveInstanceAssets(instance, options, COMPONENTS)
resolveInstanceAssets(instance, options, DIRECTIVES)
if (__COMPAT__ && isCompatEnabled(DeprecationTypes.FILTERS, instance)) {
resolveInstanceAssets(instance, options, FILTERS)
}
}
}

function resolveInstanceAssets(
Expand Down