Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #8865: skip mixins and extends if child is already merged #8870

Merged
merged 3 commits into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/util/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,10 @@ export function mergeOptions (
normalizeInject(child, vm)
normalizeDirectives(child)
const extendsFrom = child.extends
if (extendsFrom) {
if (extendsFrom && !child._base) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there's some other flag that's supposed to be used for this, but the presence of _base seemed like a decent indicator at a glance.

parent = mergeOptions(parent, extendsFrom, vm)
}
if (child.mixins) {
if (child.mixins && !child._base) {
for (let i = 0, l = child.mixins.length; i < l; i++) {
parent = mergeOptions(parent, child.mixins[i], vm)
}
Expand Down
19 changes: 19 additions & 0 deletions test/unit/features/global-api/extend.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ describe('Global API: extend', () => {
expect(calls).toEqual([1, 2, 3])
})

it('should not merge nested mixins', () => {
KaelWD marked this conversation as resolved.
Show resolved Hide resolved
const A = Vue.extend({
created: () => {}
})
const B = Vue.extend({
mixins: [A],
created: () => {}
})
const C = Vue.extend({
extends: B,
created: () => {}
})
const D = Vue.extend({
mixins: [C],
created: () => {}
})
expect(D.options.created.length).toBe(4)
})

it('should merge methods', () => {
const A = Vue.extend({
methods: {
Expand Down