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