mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
fix(core): fix merged twice bug when passing extended constructor to mixins (#9199)
fix #9198
This commit is contained in:
parent
d21e931396
commit
743edacdb6
@ -376,7 +376,7 @@ export function mergeOptions (
|
||||
}
|
||||
|
||||
if (typeof child === 'function') {
|
||||
child = child.options
|
||||
child = child.extendOptions
|
||||
}
|
||||
|
||||
normalizeProps(child, vm)
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user