fix(ivy): move views that are already attached in insert() (#29047)

Currently if a user accidentally calls ViewContainerRef.insert() with
a view that has already been attached, we do not clean up the references
properly, so we create a view tree with a cycle. This causes an infinite
loop when the view is destroyed.

This PR ensures that we fall back to ViewContainerRef.move() behavior
if we try to insert a view that is already attached. This fixes the
cycle and honors the user intention.

PR Close #29047
This commit is contained in:
Kara Erickson
2019-03-01 13:45:02 -08:00
committed by Andrew Kushnir
parent ff8e4dddb2
commit 7ac58bec8a
9 changed files with 148 additions and 312 deletions

View File

@ -354,6 +354,7 @@ export function detachView(lContainer: LContainer, removeIndex: number): LView {
viewToDetach[QUERIES] !.removeView();
}
viewToDetach[PARENT] = null;
viewToDetach[NEXT] = null;
// Unsets the attached flag
viewToDetach[FLAGS] &= ~LViewFlags.Attached;
return viewToDetach;