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

model.changedAttributes() behaves inconsistently #3579

Closed
cibernox opened this issue Jul 23, 2015 · 1 comment · Fixed by #3582
Closed

model.changedAttributes() behaves inconsistently #3579

cibernox opened this issue Jul 23, 2015 · 1 comment · Fixed by #3582

Comments

@cibernox
Copy link
Contributor

I've observed that DS.Model.changedAttributes() behaves differently on new records than on saved ones (the behaviour on the saved models looks correct to me, the one in the new records seems as bug)

If you create a new record and change some of its attributes, model.changedAttributes() will return an object with the properties that have changed and the current and previous value, and model.isDirty is true. So far so good.

But when you save it, while the request is pending and the record is still being saved, on the new record the changed attributes is cleared (an empty object), while on the already saved record it the changed attributes don't change until the save operation completes.

The behaviour of the saved records seems the right one. The dirty attributes should remain dirty until we get confirmation from the API).

In both cases the record's isDirty property is true, is just the changedAttributes() function the one that returns the wrong value.

Reproducible live example: http://development.dummy-app.divshot.io/ember-data-dirty-bug
Code: https://github.com/cibernox/dummy-app-for-benchmark

Also I'm curious about why changedAttributes is a function and not a computedProperty.

@cibernox cibernox changed the title mode.changedAttributes() behaves inconsistently model.changedAttributes() behaves inconsistently Jul 23, 2015
@cibernox
Copy link
Contributor Author

Just for the record, I've fixed this myself. I'm struggling a bit to add a proper test harness bug hopefully I should have a fix tonight.

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 a pull request may close this issue.

1 participant