Skip to content

Commit 9627509

Browse files
sis0k0hdeshev
authored andcommitted
fix(renderer): stop inserting Placeholders children
1 parent 809bf10 commit 9627509

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
@@ -88,7 +88,10 @@ export class NativeScriptRenderer extends RendererV2 {
8888

8989
appendChild(parent: any, newChild: NgView): void {
9090
traceLog(`NativeScriptRenderer.appendChild child: ${newChild} parent: ${parent}`);
91-
this.viewUtil.insertChild(parent, newChild);
91+
92+
if (parent) {
93+
this.viewUtil.insertChild(parent, newChild);
94+
}
9295
}
9396

9497
insertBefore(parent: NgView, newChild: NgView, refChildIndex: number): void {
@@ -199,7 +202,7 @@ export class NativeScriptRenderer extends RendererV2 {
199202
return this.viewUtil.createView(name);
200203
}
201204

202-
createText(_value: string): NgView {
205+
createText(_value: string) {
203206
traceLog("NativeScriptRenderer.createText");
204207
return this.viewUtil.createText();
205208
}

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type ViewExtensions = ViewExtensions;
2222
export type NgView = NgView;
2323
export type NgLayoutBase = LayoutBase & ViewExtensions;
2424
export type NgContentView = ContentView & ViewExtensions;
25+
export type NgPlaceholder = Placeholder & ViewExtensions;
2526
export type BeforeAttachAction = (view: View) => void;
2627

2728
export function isView(view: any): view is NgView {
@@ -36,6 +37,10 @@ export function isContentView(view: any): view is NgContentView {
3637
return view instanceof ContentView;
3738
}
3839

40+
export function isPlaceholder(view: any): view is NgPlaceholder {
41+
return view instanceof Placeholder;
42+
}
43+
3944
const propertyMaps: Map<Function, Map<string, string>> = new Map<Function, Map<string, string>>();
4045

4146
export class ViewUtil {
@@ -48,7 +53,7 @@ export class ViewUtil {
4853
}
4954

5055
public insertChild(parent: any, child: NgView, atIndex: number = -1) {
51-
if (!parent || child.meta.skipAddToDom) {
56+
if (!parent || child.meta.skipAddToDom || isPlaceholder(child) === true) {
5257
return;
5358
}
5459

0 commit comments

Comments
 (0)