Skip to content

Commit 6f5d6f7

Browse files
telerikusersis0k0
telerikuser
authored andcommitted
refactor(view-util): extract the lookup for next visual view into method
1 parent ffe0397 commit 6f5d6f7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

+12-7
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,24 @@ export class ViewUtil {
122122
this.removeLayoutChild(parent, child);
123123
}
124124

125-
// Find next actual element
126-
while (next && isDetachedElement(next)) {
127-
next = next.nextSibling;
128-
}
129-
130-
if (next) {
131-
const index = parent.getChildIndex(next);
125+
const nextVisual = this.findNextVisual(next);
126+
if (nextVisual) {
127+
const index = parent.getChildIndex(nextVisual);
132128
parent.insertChild(child, index);
133129
} else {
134130
parent.addChild(child);
135131
}
136132
}
137133

134+
private findNextVisual(view: NgView) {
135+
let next = view;
136+
while (next && isDetachedElement(next)) {
137+
next = next.nextSibling;
138+
}
139+
140+
return next;
141+
}
142+
138143
public removeChild(parent: NgView, child: NgView) {
139144
if (!parent) {
140145
return;

0 commit comments

Comments
 (0)