File tree 2 files changed +16
-5
lines changed
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ export class NativeScriptRenderer extends RendererV2 {
116
116
117
117
nextSibling ( node : NgView ) : number {
118
118
traceLog ( `NativeScriptRenderer.nextSibling ${ node } ` ) ;
119
- return this . viewUtil . nextSibling ( node ) ;
119
+ return this . viewUtil . nextSiblingIndex ( node ) ;
120
120
}
121
121
122
122
createViewRoot ( hostElement : NgView ) : NgView {
Original file line number Diff line number Diff line change @@ -202,13 +202,24 @@ export class ViewUtil {
202
202
203
203
// finds the node in the parent's views and returns the next index
204
204
// returns -1 if the node has no parent or next sibling
205
- public nextSibling ( node : NgView ) : number {
205
+ public nextSiblingIndex ( node : NgView ) : number {
206
206
const parent = node . parent ;
207
- if ( ! parent || typeof ( < any > parent ) . _subViews === "undefined" ) {
207
+
208
+ if ( ! parent ) {
208
209
return - 1 ;
209
210
} else {
210
- const index = ( < any > parent ) . _subViews . indexOf ( node ) ;
211
- return index === - 1 ? index : index + 1 ;
211
+ let index = 0 ;
212
+ let found = false ;
213
+ parent . eachChild ( child => {
214
+ if ( child === node ) {
215
+ found = true ;
216
+ }
217
+
218
+ index += 1 ;
219
+ return ! found ;
220
+ } ) ;
221
+
222
+ return found ? index : - 1 ;
212
223
}
213
224
}
214
225
You can’t perform that action at this time.
0 commit comments