adopted-ember-addons / ember-changeset

Ember.js flavored changesets, inspired by Ecto
http://bit.ly/ember-changeset-demo
MIT License
431 stars 141 forks source link

instanceof test #636

Open luxzeitlos opened 2 years ago

luxzeitlos commented 2 years ago

This is for now just a failing test, and I'm not even sure this is an error of this repo. The thing is, I'm not even sure this is a real problem and where this must be fixed.

However I'm very confident this is the error described in #629. I encountered the same Problem with a Temporal, which basically completely breaks. Utilizing .content works, however this is not nice.

The current behaviour is:


    class Foo {}
    let model = EmberObject.create({ foo: new Foo() });
    let dummyChangeset = Changeset(model);

    // this *does* work!
    assert.ok(dummyChangeset.foo.content instanceof Foo, 'content property is an instance');

    // this *does not* work!
    assert.ok(dummyChangeset.foo instanceof Foo, 'proxy itself is an instance');
snewcomer commented 2 years ago

@luxferresum @bgolla so the problem here is the intermediate value is the proxy. The assumption was that a user only ever wants the leaf key to display in the UI. So in your example,

class Foo { name = 'Scott'; } 

changeset.foo will be the proxy and changeset.foo.name === 'Scott'.

What concrete problem are you running up against?