Skip to content

Commit a59112f

Browse files
committed
fix(mergeOptions): skip mixins and extends if child is already merged
fixes vuejs#8865
1 parent 79cabad commit a59112f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/core/util/options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ export function mergeOptions (
379379
normalizeInject(child, vm)
380380
normalizeDirectives(child)
381381
const extendsFrom = child.extends
382-
if (extendsFrom) {
382+
if (extendsFrom && !child._base) {
383383
parent = mergeOptions(parent, extendsFrom, vm)
384384
}
385-
if (child.mixins) {
385+
if (child.mixins && !child._base) {
386386
for (let i = 0, l = child.mixins.length; i < l; i++) {
387387
parent = mergeOptions(parent, child.mixins[i], vm)
388388
}

test/unit/features/global-api/extend.spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,25 @@ describe('Global API: extend', () => {
7171
expect(calls).toEqual([1, 2, 3])
7272
})
7373

74+
it('should not merge nested mixins', () => {
75+
const A = Vue.extend({
76+
created: () => {}
77+
})
78+
const B = Vue.extend({
79+
mixins: [A],
80+
created: () => {}
81+
})
82+
const C = Vue.extend({
83+
extends: B,
84+
created: () => {}
85+
})
86+
const D = Vue.extend({
87+
mixins: [C],
88+
created: () => {}
89+
})
90+
expect(D.options.created.length).toBe(4)
91+
})
92+
7493
it('should merge methods', () => {
7594
const A = Vue.extend({
7695
methods: {

0 commit comments

Comments
 (0)