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

Beta 4: invalid context(this) of mixins when used vuex and custom mixin #885

Closed
armano2 opened this issue Feb 15, 2019 · 1 comment
Closed

Comments

@armano2
Copy link

armano2 commented Feb 15, 2019

Version

5.0.0-beta.4

Browser and OS info

Windows 10 / Firefox

Steps to reproduce

Edit Vue Template

import Vue from "vue";
import Vuex from "vuex";

function mixin(_Vue) {
  _Vue.mixin({
    computed: {
      test() {
        if (this.$options.test) {
          return this.$options.test;
        }
        throw new Error("test is not defined");
      }
    }
  });
}

Vue.use(mixin);
Vue.use(Vuex);

/* eslint-disable no-new */
new Vue({
  el: "#app",
  test: 1,
  store: new Vuex.Store({
    state: {
      a: 1
    }
  }),
  computed: {
    foo() {
      return this.$store.state.a;
    }
  },
  template: `<div id="app">
    <h1>{{ test }}</h1>
    <h2>{{ foo }}</h2>
  </div>`
});

What is expected?

No error

What is actually happening?

test is not defined


DevTools are changing context (this) of mixins when store is registered as Vuex.Store instance.
This issue is present only in beta branch of devTools.

This issue is not present when instead of instance of store i provide object.

  store: {
    state: {
      a: 1
    }
  },

EDIT:

i did small simplification of reproduce code

@armano2 armano2 changed the title invalid context when used vue + vuex + vue-router + custom mixin Error: invalid context(this) of mixins when used vue + vuex + vue-router + custom mixin and devtools beta Feb 15, 2019
@armano2 armano2 changed the title Error: invalid context(this) of mixins when used vue + vuex + vue-router + custom mixin and devtools beta regression(beta-4): invalid context(this) of mixins when used vue + vuex + vue-router + custom mixin and devtools beta Feb 15, 2019
@armano2 armano2 changed the title regression(beta-4): invalid context(this) of mixins when used vue + vuex + vue-router + custom mixin and devtools beta Beta 4: invalid context(this) of mixins when used vue + vuex + vue-router + custom mixin and devtools beta Feb 15, 2019
@armano2 armano2 changed the title Beta 4: invalid context(this) of mixins when used vue + vuex + vue-router + custom mixin and devtools beta Beta 4: invalid context(this) of mixins when used vuex and custom mixin Feb 15, 2019
sp1ker added a commit to sp1ker/vue-devtools that referenced this issue Mar 16, 2019
Akryum pushed a commit to sp1ker/vue-devtools that referenced this issue Mar 20, 2019
@Akryum
Copy link
Member

Akryum commented Mar 20, 2019

Closed in #904

@Akryum Akryum closed this as completed Mar 20, 2019
simsim0709 pushed a commit to simsim0709/vue-devtools that referenced this issue May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants