Skip to content

Commit dce5108

Browse files
author
Alexander Vakrilov
authored
fix: revert recursie remove -causing crashes (NativeScript#1819)
1 parent ad6ac94 commit dce5108

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

nativescript-angular/router/page-router-outlet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
358358
// Component loaded. Find its root native view.
359359
const componentView = componentRef.location.nativeElement;
360360
// Remove it from original native parent.
361-
this.viewUtil.removeChild(componentView.parent, componentView, false);
361+
this.viewUtil.removeChild(componentView.parent, componentView);
362362
// Add it to the new page
363363
this.viewUtil.insertChild(page, componentView);
364364

nativescript-angular/view-util.ts

+2-14
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ export class ViewUtil {
157157
return next;
158158
}
159159

160-
public removeChild(parent: View, child: View, removeGrandchildren = true) {
160+
public removeChild(parent: View, child: View) {
161161
if (isLogEnabled()) {
162-
traceLog(`ViewUtil.removeChild parent: ${parent} child: ${child} `
163-
+ `remove grandchildren: ${removeGrandchildren}`);
162+
traceLog(`ViewUtil.removeChild parent: ${parent} child: ${child}`);
164163
}
165164

166165
if (!parent) {
@@ -170,17 +169,6 @@ export class ViewUtil {
170169
const extendedParent = this.ensureNgViewExtensions(parent);
171170
const extendedChild = this.ensureNgViewExtensions(child);
172171

173-
// Remove the child's children and their children
174-
// Unless called from PageRouterOutlet when the child is moved from once parent to another.
175-
while (extendedChild && extendedChild.firstChild && removeGrandchildren) {
176-
const grandchild = extendedChild.firstChild;
177-
if (isLogEnabled()) {
178-
traceLog(`ViewUtil.removeChild parent: ${parent} child: ${extendedChild} grandchild: ${grandchild}`);
179-
}
180-
181-
this.removeChild(extendedChild, grandchild);
182-
}
183-
184172
this.removeFromQueue(extendedParent, extendedChild);
185173
if (!isDetachedElement(extendedChild)) {
186174
this.removeFromVisualTree(extendedParent, extendedChild);

0 commit comments

Comments
 (0)