File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 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 {
121121
122122 nextSibling ( node : NgView ) : number {
123123 traceLog ( `NativeScriptRenderer.nextSibling ${ node } ` ) ;
124- return this . viewUtil . nextSibling ( node ) ;
124+ return this . viewUtil . nextSiblingIndex ( node ) ;
125125 }
126126
127127 createViewRoot ( hostElement : NgView ) : NgView {
Original file line number Diff line number Diff line change @@ -199,13 +199,24 @@ export class ViewUtil {
199199
200200 // finds the node in the parent's views and returns the next index
201201 // returns -1 if the node has no parent or next sibling
202- public nextSibling ( node : NgView ) : number {
202+ public nextSiblingIndex ( node : NgView ) : number {
203203 const parent = node . parent ;
204- if ( ! parent || typeof ( < any > parent ) . _subViews === "undefined" ) {
204+
205+ if ( ! parent ) {
205206 return - 1 ;
206207 } 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 ;
209220 }
210221 }
211222
You can’t perform that action at this time.
0 commit comments