fix(core): fix merged twice bug when passing extended constructor to mixins (#9199)

fix #9198
This commit is contained in:
hikerpig 2019-01-11 05:10:54 +08:00 committed by Evan You
parent d21e931396
commit 743edacdb6
2 changed files with 30 additions and 2 deletions

View File

@ -376,7 +376,7 @@ export function mergeOptions (
}
if (typeof child === 'function') {
child = child.options
child = child.extendOptions
}
normalizeProps(child, vm)

View File

@ -109,4 +109,32 @@ describe('Options mixins', () => {
expect(vm.b).toBeDefined()
expect(vm.$options.directives.c).toBeDefined()
})
it('should not mix global mixined lifecycle hook twice', () => {
const spy = jasmine.createSpy('global mixed in lifecycle hook')
Vue.mixin({
created() {
spy()
}
})
const mixin1 = Vue.extend({
methods: {
a() {}
}
})
const mixin2 = Vue.extend({
mixins: [mixin1],
})
const Child = Vue.extend({
mixins: [mixin2],
})
const vm = new Child()
expect(typeof vm.$options.methods.a).toBe('function')
expect(spy.calls.count()).toBe(1)
})
})