diff --git a/src/install.ts b/src/install.ts index 0b4b3652..b7554e83 100644 --- a/src/install.ts +++ b/src/install.ts @@ -9,6 +9,8 @@ import { VueConstructor } from 'vue' */ function mergeData(from: AnyObject, to: AnyObject): Object { if (!from) return to + if (!to) return from + let key: any let toVal: any let fromVal: any @@ -56,8 +58,8 @@ export function install( ) { return function mergedSetupFn(props: any, context: any) { return mergeData( - typeof parent === 'function' ? parent(props, context) || {} : {}, - typeof child === 'function' ? child(props, context) || {} : {} + typeof parent === 'function' ? parent(props, context) || {} : undefined, + typeof child === 'function' ? child(props, context) || {} : undefined ) } } diff --git a/test/setup.spec.js b/test/setup.spec.js index 99e30eff..d11a0284 100644 --- a/test/setup.spec.js +++ b/test/setup.spec.js @@ -719,4 +719,16 @@ describe('setup', () => { expect(context).toBe(vm) }) }) + + it('should work after extending with an undefined setup', () => { + const opts = { + setup() { + return () => h('div', 'Composition-api') + }, + } + const Constructor = Vue.extend(opts).extend({}) + + const vm = new Vue(Constructor).$mount() + expect(vm.$el.textContent).toBe('Composition-api') + }) })