Skip to content

instances of classes are not displayed in data inspector #199

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

Open
rpkilby opened this issue Dec 12, 2016 · 3 comments
Open

instances of classes are not displayed in data inspector #199

rpkilby opened this issue Dec 12, 2016 · 3 comments

Comments

@rpkilby
Copy link

rpkilby commented Dec 12, 2016

When using a plain object, both name and _name are displayed in the data inspector

new Vue({
    el: '#app',
    data: {
        customer: {
            _name: 'John Doe',
            get name() {
                return this._name;
            },

            set name(value) {
                console.log(`name set to: ${value}`);
                this._name = value;
            },
        },
    },
});

In this case, the inherited name property is missing from the data inspector

class Person {
    constructor() {
        this._name = 'John Doe';
    }

    get name() {
        return this._name;
    }

    set name(value) {
        console.log(`name set to: ${value}`);
        this._name = value;
    }
}

new Vue({
    el: '#app',
    data: {
        customer: new Person(),
    },
});

From an implementation standpoint, this might be related to vuejs/vue/issues/3610

@posva posva changed the title Inherited properties are not displayed in data inspector instances of classes are displayed in data inspector Jan 16, 2017
@posva posva changed the title instances of classes are displayed in data inspector instances of classes are not displayed in data inspector Jan 17, 2017
@Akryum Akryum added the bug label Jan 4, 2018
@ericnilo
Copy link

Also whenever I commit/time travel the specific mutation in vuex (devtools) it becomes a plain Object instead of the original instance of the state/data

e.g.

image

state.form is an instance of Form class and state.form.errors is an instance of Error class, after commit/time travel, state.form and state.form.errors just became an Object instance :( and I get this error:

image

@ryuuji3
Copy link

ryuuji3 commented Jan 13, 2019

I also have this behaviour when rewinding state. My state happens to be a class, but becomes a plain object; which causes a runtime exception when it attempts to call a prototype method which doesn't exist.

@jods4
Copy link

jods4 commented Jul 21, 2021

Sadly this is still the same in devtools 6.0.0-beta.15.

I suppose only owned keys are displayed in the data panel. When using classes, getter/setter properties are found on the object prototype.

This could be mitigated by a menu entry in the 3-dots menu was added to create a global variable, similar to $0 in the DOM explorer, that you could then dump on the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants