Skip to content

Vue does not correctly dedupe global mixin, global mixined lifecycle hook be called twice #9198

@hikerpig

Description

@hikerpig

Version

2.5.21

Reproduction link

https://codepen.io/hikerpig/pen/dwYEej

Steps to reproduce

Goto the minimal reproduction link

Or simply add this to test/unit/features/options/mixins.spec.js

  it('should not mix global mixined lifecycle hook twice', () => {
    const spy = jasmine.createSpy('global mixed in lifecycle hook')
    Vue.mixin({
      created() {
        spy()
      }
    })

    const mixin = Vue.extend({})

    const Child = Vue.extend({
      mixins: [mixin],
      created() {}
    })

    const vm = new Child()

    expect(spy.calls.count()).toBe(1)
  })

What is expected?

spy to be called once

What is actually happening?

spy is called twice


When using vue-class-component , it's easy to pass not-plain-object to Vue.extends mixins

I've added a similar issue in vuejs/vue-class-component#291 , and it is still not fixed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions