Skip to content

Commit e7ab3c5

Browse files
committed
refactor: unify parentNode access
The logic for setting/getting template parent is delegated to the ViewBase class.
1 parent bb298b4 commit e7ab3c5

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Diff for: nativescript-angular/directives/action-bar.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ const actionBarMeta: ViewClassMeta = {
3434
return;
3535
} else if (isNavigationButton(child)) {
3636
parent.navigationButton = child;
37-
child.templateParent = parent;
37+
child.parentNode = parent;
3838
} else if (isActionItem(child)) {
3939
addActionItem(parent, child, next);
40-
child.templateParent = parent;
40+
child.parentNode = parent;
4141
} else if (isView(child)) {
4242
parent.titleView = child;
4343
}
@@ -50,10 +50,10 @@ const actionBarMeta: ViewClassMeta = {
5050
parent.navigationButton = null;
5151
}
5252

53-
child.templateParent = null;
53+
child.parentNode = null;
5454
} else if (isActionItem(child)) {
5555
parent.actionItems.removeItem(child);
56-
child.templateParent = null;
56+
child.parentNode = null;
5757
} else if (isView(child) && parent.titleView && parent.titleView === child) {
5858
parent.titleView = null;
5959
}

Diff for: nativescript-angular/element-registry.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface ViewExtensions {
77
meta: ViewClassMeta;
88
nodeType: number;
99
nodeName: string;
10-
templateParent: NgView;
10+
parentNode: NgView;
1111
nextSibling: NgView;
1212
firstChild: NgView;
1313
lastChild: NgView;
@@ -22,7 +22,7 @@ export abstract class InvisibleNode extends View implements NgView {
2222
meta: { skipAddToDom: boolean };
2323
nodeType: number;
2424
nodeName: string;
25-
templateParent: NgView;
25+
parentNode: NgView;
2626
nextSibling: NgView;
2727
firstChild: NgView;
2828
lastChild: NgView;

Diff for: nativescript-angular/renderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class NativeScriptRenderer extends Renderer2 {
116116
@profile
117117
parentNode(node: NgView): any {
118118
traceLog(`NativeScriptRenderer.parentNode for node: ${node}`);
119-
return node.parent || node.templateParent;
119+
return node.parentNode;
120120
}
121121

122122
@profile

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class ViewUtil {
6969
this.addToQueue(extendedParent, extendedChild, previous, next);
7070

7171
if (isInvisibleNode(child)) {
72-
extendedChild.templateParent = extendedParent;
72+
extendedChild.parentNode = extendedParent;
7373
}
7474

7575
if (!isDetachedElement(child)) {

0 commit comments

Comments
 (0)