Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nativescript-angular/router/page-router-outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 2 additions & 14 deletions nativescript-angular/view-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down