You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The root cause is in DefineList which implements the can.updateDeep symbol by aliasing to this.replace.
The latter does a shallow update based on can-diff key diffs and does not deep update the entities in the list.
It seems there is an assumption that updates will always flow through a centralized constructor-store behavior from can-connect, where it would have taken care to update the entities.
That assumption is imho false.
There are reasons to attach identity keys to entities that don't flow through such a behavior.
For instance;
A particular entity serving as a member of a list may only ever be fetched as part of a greater object graph where its 'parent' entity is the only one with a can-connect pipeline attached to it. But you still want to give that member entity an identity to minimize dom churn when rendering it with a {{#for (of)}} stache helper.
Proposed solution
Update either the replace method or the can.updateDeep symbol implementation on DefineList.
Neither really does what it says on the tin.
The deep update is definitely not deep. And the list members are not replaced; i.e. are not updated to the point where their new state looks like they were fully replaced.
The text was updated successfully, but these errors were encountered:
rjgotten
changed the title
Can 5.33.x | Reflect.updateDeep doesn't deep update into list members
Can 5.x | Reflect.updateDeep doesn't deep update into list members
Nov 24, 2020
Assume the following model definitions and data:
Use
Reflect.updateDeep
to update with new data, like so:Expected value for
root
Actual value for
root
The root cause is in
DefineList
which implements thecan.updateDeep
symbol by aliasing tothis.replace
.The latter does a shallow update based on
can-diff
key diffs and does not deep update the entities in the list.It seems there is an assumption that updates will always flow through a centralized
constructor-store
behavior fromcan-connect
, where it would have taken care to update the entities.That assumption is imho false.
There are reasons to attach identity keys to entities that don't flow through such a behavior.
For instance;
A particular entity serving as a member of a list may only ever be fetched as part of a greater object graph where its 'parent' entity is the only one with a
can-connect
pipeline attached to it. But you still want to give that member entity an identity to minimize dom churn when rendering it with a{{#for (of)}}
stache helper.Proposed solution
Update either the
replace
method or thecan.updateDeep
symbol implementation onDefineList
.Neither really does what it says on the tin.
The deep update is definitely not deep. And the list members are not replaced; i.e. are not updated to the point where their new state looks like they were fully replaced.
The text was updated successfully, but these errors were encountered: