diff --git a/packages/runtime-core/__tests__/apiCreateApp.spec.ts b/packages/runtime-core/__tests__/apiCreateApp.spec.ts index 0c7faf711..c3be3476c 100644 --- a/packages/runtime-core/__tests__/apiCreateApp.spec.ts +++ b/packages/runtime-core/__tests__/apiCreateApp.spec.ts @@ -457,7 +457,7 @@ describe('api: createApp', () => { app.config.optionMergeStrategies.foo = (a, b) => (a ? `${a},` : ``) + b app.mount(nodeOps.createElement('div')) - expect(merged!).toBe('local,extends,mixin,global') + expect(merged!).toBe('global,extends,mixin,local') }) test('config.globalProperties', () => { diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 5af8c410d..fd4737147 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -768,23 +768,24 @@ export function resolveMergedOptions( const globalMixins = instance.appContext.mixins if (!globalMixins.length && !mixins && !extendsOptions) return raw const options = {} - mergeOptions(options, raw, instance) globalMixins.forEach(m => mergeOptions(options, m, instance)) + mergeOptions(options, raw, instance) return (raw.__merged = options) } function mergeOptions(to: any, from: any, instance: ComponentInternalInstance) { const strats = instance.appContext.config.optionMergeStrategies - for (const key in from) { - if (strats && hasOwn(strats, key)) { - to[key] = strats[key](to[key], from[key], instance.proxy, key) - } else if (!hasOwn(to, key)) { - to[key] = from[key] - } - } const { mixins, extends: extendsOptions } = from extendsOptions && mergeOptions(to, extendsOptions, instance) mixins && mixins.forEach((m: ComponentOptionsMixin) => mergeOptions(to, m, instance)) + + for (const key in from) { + if (strats && hasOwn(strats, key)) { + to[key] = strats[key](to[key], from[key], instance.proxy, key) + } else { + to[key] = from[key] + } + } }