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

readonly() breaks comparison between objects #4986

Closed
jvgpinheiro opened this issue Nov 23, 2021 · 3 comments
Closed

readonly() breaks comparison between objects #4986

jvgpinheiro opened this issue Nov 23, 2021 · 3 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: reactivity

Comments

@jvgpinheiro
Copy link

Version

3.2.21

Problem

I had an object A that used some data from a readonly object B, but after reassigning the props from object A and try to compare the prop to the equivalent data from object B, the result of the comparison was false when I expected to be true.

I managed to work around this by comparing the internal properties from both objects, but I'd like to know what it's expected to return in the case bellow

Steps to reproduce

class Type {
    constructor(code) {
        this.code = code;
    }
    
    getCode() {
        return this.code;
    }
}

simpler = readonly({ a: new Type(0), b: new Type(1) });
moreComplex = reactive({ a: simpler.a, b: simpler.b });
console.log(`Before: ${moreComplex.a === simpler.a}`);
moreComplex.a = simpler.b;
moreComplex.a = simpler.a;
console.log(`After: ${moreComplex.a === simpler.a}`);
@vue-bot
Copy link

vue-bot commented Nov 23, 2021

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

@vue-bot vue-bot closed this as completed Nov 23, 2021
@yyx990803 yyx990803 reopened this Nov 25, 2021
@yyx990803
Copy link
Member

yyx990803 commented Nov 25, 2021

Looks like a legit bug, but a bit of an edge case.

@yyx990803 yyx990803 added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: reactivity and removed 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Nov 25, 2021
@jvgpinheiro
Copy link
Author

Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: reactivity
Projects
None yet
Development

No branches or pull requests

3 participants