Skip to content

Commit

Permalink
clear initialState after construction (#7110)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieter-v authored and runspired committed Apr 24, 2020
1 parent 5feedc8 commit 605b3ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ module('integration/relationships/has_many - Has-Many Relationships', function(h
});

test('hasMany + canonical vs currentState + destroyRecord ', function(assert) {
assert.expect(6);
assert.expect(7);

let store = this.owner.lookup('service:store');

Expand Down Expand Up @@ -266,6 +266,8 @@ module('integration/relationships/has_many - Has-Many Relationships', function(h
);
assert.equal(contacts, user.get('contacts'));

assert.ok(!user.contacts.initialState || !user.contacts.initialState.find(model => model.id === '2'));

run(() => {
contacts.addObject(store.createRecord('user', { id: 8 }));
});
Expand Down
2 changes: 2 additions & 0 deletions packages/model/addon/-private/system/many-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export default EmberObject.extend(MutableArray, DeprecatedEvented, {
*/
this.currentState = [];
this.flushCanonical(this.initialState, false);
// we don't need this anymore, it just prevents garbage collection the records in the initialState
this.initialState = undefined;
},

// TODO: if(DEBUG)
Expand Down

0 comments on commit 605b3ba

Please sign in to comment.