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
{{ message }}
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.
TLDR;
a sort event on a CollectionView's collection adds new ItemViews for each model to this.children and to the DOM, but does not remove the old ItemViews from this.children; the old ItemViews are retained indefinitely.
I'm unsure if this is a bug or if I am doing something wrong.
sort event on collection -> CollectionView#onCollectionReset()
CollectionView#onCollectionReset() -> CollectionView#renderCollection()
CollectionView#renderCollection() -> CollectionView#appendItem() for each model
TLDR;
a sort event on a CollectionView's collection adds new ItemViews for each model to
this.children
and to the DOM, but does not remove the old ItemViews fromthis.children
; the old ItemViews are retained indefinitely.Here is a jsfiddle showing the problem.
I'm unsure if this is a bug or if I am doing something wrong.
sort event on collection -> CollectionView#onCollectionReset()
CollectionView#onCollectionReset() -> CollectionView#renderCollection()
CollectionView#renderCollection() -> CollectionView#appendItem() for each model
appendItem uses CollectionView#renderItem to produce a new view for the model.
https://github.com/walmartlabs/thorax/blob/v3.0.0-beta.5/src/collection.js#L226
If the new view has a cid, View#_addChild adds the new view to this.children, among other things.
https://github.com/walmartlabs/thorax/blob/v3.0.0-beta.5/src/collection.js#L230-233
Why not reuse the existing ItemViews in this.children in response to a sort event? Am I missing something?
In general, it looks like old ItemViews are not removed in CollectionView#onCollectionReset.
The text was updated successfully, but these errors were encountered: