Closed dwickern closed 1 year ago
It's a problem with our property change tracking, but I'm not sure how to fix it.
createRecord('person', { titles: ... })
desugars to:
const person = store.createRecord('person');
person.titles.setObjects(['Hand of the King', 'Master of Coin']);
MutableArray.setObjects calls length
and then replace
, which effectively calls get('[]')
followed by notifyPropertyChange('[]')
I've added a second test which depends on the get(this, '[]')
call inside length
to initiate auto-tracking. If I remove that line, the first test passes but the second test fails. The code was originally from https://github.com/emberjs/data/pull/7330.
My goal here is to get both tests passing.
I should add that this bug was not introduced in model-fragments v6, it's also present in v5.
My workaround 10a7825cc3049d54674905ed52906647093f368c implements setObjects
without calling length
. Both tests pass. It's not a perfect solution, but probably good enough?
This issue was reported before in #357
Released as 6.0.1
Fixes https://github.com/adopted-ember-addons/ember-data-model-fragments/issues/357
Constructing a record throws an error:
This happens when we initialize a fragment array while a render loop is running.