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 findSiblings and the target kept its prototype #175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sapryniukt
Copy link

@sapryniukt sapryniukt commented Aug 2, 2022

We ran into the issue of losing prototype and incorrect invocation of setDeep when tried to change the EmberData property in the changeset.

My changeset looked something like this:

data: {
    "name": "Jim Bob",
    "address": CountryModel {
        "country": "US",
        "address1": "",
    }
}

but after execution:

changeset.set("address.address1", "some");

We got:

changes: {
    "name": "Jim Bob",
    "address": Object {
        "address1": "some",
    }
}

Looks like findSiblings works well with POJO, but doesn't consider Class object.
I proppose a simple solution to this by using

Object.setPrototypeOf(obj, prototype)

or

Object.create(prototype)

Also the tests that check and reproduce the issue have been added.

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

Successfully merging this pull request may close these issues.

1 participant