Skip to content

Commit

Permalink
fix: only set inheritAttrs from mixin if component self does not have
Browse files Browse the repository at this point in the history
the option
  • Loading branch information
yyx990803 committed May 28, 2021
1 parent 1243c97 commit 072b35f
Showing 1 changed file with 21 additions and 17 deletions.
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
}

// 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

0 comments on commit 072b35f

Please sign in to comment.