Skip to content

Commit 6dd8b18

Browse files
committed
fix(renderer): respect templateParent in parentNode() if one is set
fixes #777, fixes #787
1 parent 05260b7 commit 6dd8b18

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

Diff for: nativescript-angular/renderer.ts

+5-13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class NativeScriptRendererFactory implements RendererFactory2 {
4343
if (!rootView) {
4444
rootView = getRootPage() || topmost().currentPage;
4545
}
46+
4647
rootView.nodeName = "NONE";
4748
this.rootNgView = rootView;
4849
}
@@ -83,26 +84,17 @@ export class NativeScriptRenderer extends Renderer2 {
8384

8485
appendChild(parent: any, newChild: NgView): void {
8586
traceLog(`NativeScriptRenderer.appendChild child: ${newChild} parent: ${parent}`);
86-
87-
if (parent) {
88-
this.viewUtil.insertChild(parent, newChild);
89-
}
87+
this.viewUtil.insertChild(parent, newChild);
9088
}
9189

9290
insertBefore(parent: NgView, newChild: NgView, refChildIndex: number): void {
9391
traceLog(`NativeScriptRenderer.insertBefore child: ${newChild} parent: ${parent}`);
94-
95-
if (parent) {
96-
this.viewUtil.insertChild(parent, newChild, refChildIndex);
97-
}
92+
this.viewUtil.insertChild(parent, newChild, refChildIndex);
9893
}
9994

10095
removeChild(parent: any, oldChild: NgView): void {
10196
traceLog(`NativeScriptRenderer.removeChild child: ${oldChild} parent: ${parent}`);
102-
103-
if (parent) {
104-
this.viewUtil.removeChild(parent, oldChild);
105-
}
97+
this.viewUtil.removeChild(parent, oldChild);
10698
}
10799

108100
selectRootElement(selector: string): NgView {
@@ -111,7 +103,7 @@ export class NativeScriptRenderer extends Renderer2 {
111103
}
112104

113105
parentNode(node: NgView): any {
114-
return node.parent;
106+
return node.parent || node.templateParent;
115107
}
116108

117109
nextSibling(node: NgView): number {

0 commit comments

Comments
 (0)