Skip to content

Commit 08a7073

Browse files
committed
fix(renderer): stop inserting Placeholders children
1 parent 98d9d20 commit 08a7073

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Diff for: nativescript-angular/renderer.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ export class NativeScriptRenderer extends RendererV2 {
8383

8484
appendChild(parent: any, newChild: NgView): void {
8585
traceLog(`NativeScriptRenderer.appendChild child: ${newChild} parent: ${parent}`);
86-
this.viewUtil.insertChild(parent, newChild);
86+
87+
if (parent) {
88+
this.viewUtil.insertChild(parent, newChild);
89+
}
8790
}
8891

8992
insertBefore(parent: NgView, newChild: NgView, refChildIndex: number): void {
@@ -194,7 +197,7 @@ export class NativeScriptRenderer extends RendererV2 {
194197
return this.viewUtil.createView(name);
195198
}
196199

197-
createText(_value: string): NgView {
200+
createText(_value: string) {
198201
traceLog("NativeScriptRenderer.createText");
199202
return this.viewUtil.createText();
200203
}

Diff for: nativescript-angular/view-util.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type ViewExtensions = ViewExtensions;
2525
export type NgView = NgView;
2626
export type NgLayoutBase = LayoutBase & ViewExtensions;
2727
export type NgContentView = ContentView & ViewExtensions;
28+
export type NgPlaceholder = Placeholder & ViewExtensions;
2829
export type BeforeAttachAction = (view: View) => void;
2930

3031
export function isView(view: any): view is NgView {
@@ -39,6 +40,10 @@ export function isContentView(view: any): view is NgContentView {
3940
return view instanceof ContentView;
4041
}
4142

43+
export function isPlaceholder(view: any): view is NgPlaceholder {
44+
return view instanceof Placeholder;
45+
}
46+
4247
const propertyMaps: Map<Function, Map<string, string>> = new Map<Function, Map<string, string>>();
4348

4449
export class ViewUtil {
@@ -51,7 +56,7 @@ export class ViewUtil {
5156
}
5257

5358
public insertChild(parent: any, child: NgView, atIndex: number = -1) {
54-
if (!parent || child.meta.skipAddToDom) {
59+
if (!parent || child.meta.skipAddToDom || isPlaceholder(child) === true) {
5560
return;
5661
}
5762

0 commit comments

Comments
 (0)