-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
When subclassing MutableArray it is surprising that any mutation can trigger objectAt(0) and objectAt(len -1). This happens because of the checks here for triggering change events for firstObject and lastObject.
This causes some difficulties when dematerializing records in Ember Data, because removing unloaded records from relationships, which is done asynchronously, would cause other records to be rematerialized because the materialization is lazy and the records are retrieved for the sake of this check.
This was reported in #5379 which was never fixed, but was closed in favour of a more limited problem in #5591 which was fixed in #14493.
One possible solution is to trigger changes for firstObject and lastObject only based on the indices of deletions and additions. This will mean that change events will be triggered even in the case of [a,a,b].removeAt(0); which is not the case today.
cc @igorT