diff --git a/nativescript-angular/router/page-router-outlet.ts b/nativescript-angular/router/page-router-outlet.ts index fb9be5320..34ba4446f 100644 --- a/nativescript-angular/router/page-router-outlet.ts +++ b/nativescript-angular/router/page-router-outlet.ts @@ -358,7 +358,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire // Component loaded. Find its root native view. const componentView = componentRef.location.nativeElement; // Remove it from original native parent. - this.viewUtil.removeChild(componentView.parent, componentView, false); + this.viewUtil.removeChild(componentView.parent, componentView); // Add it to the new page this.viewUtil.insertChild(page, componentView); diff --git a/nativescript-angular/view-util.ts b/nativescript-angular/view-util.ts index 6a8fbcb5b..faeb62329 100644 --- a/nativescript-angular/view-util.ts +++ b/nativescript-angular/view-util.ts @@ -157,10 +157,9 @@ export class ViewUtil { return next; } - public removeChild(parent: View, child: View, removeGrandchildren = true) { + public removeChild(parent: View, child: View) { if (isLogEnabled()) { - traceLog(`ViewUtil.removeChild parent: ${parent} child: ${child} ` - + `remove grandchildren: ${removeGrandchildren}`); + traceLog(`ViewUtil.removeChild parent: ${parent} child: ${child}`); } if (!parent) { @@ -170,17 +169,6 @@ export class ViewUtil { const extendedParent = this.ensureNgViewExtensions(parent); const extendedChild = this.ensureNgViewExtensions(child); - // Remove the child's children and their children - // Unless called from PageRouterOutlet when the child is moved from once parent to another. - while (extendedChild && extendedChild.firstChild && removeGrandchildren) { - const grandchild = extendedChild.firstChild; - if (isLogEnabled()) { - traceLog(`ViewUtil.removeChild parent: ${parent} child: ${extendedChild} grandchild: ${grandchild}`); - } - - this.removeChild(extendedChild, grandchild); - } - this.removeFromQueue(extendedParent, extendedChild); if (!isDetachedElement(extendedChild)) { this.removeFromVisualTree(extendedParent, extendedChild);