Skip to content

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