@@ -52,7 +52,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
5252 this . isStriped = striped ;
5353 let startsWithOdd = true ;
5454 if ( this . visibleNodes . length ) {
55- const allChildren = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
55+ const allChildren = this . filteredNodes ( ) ;
5656 startsWithOdd = Boolean ( allChildren . indexOf ( this . visibleNodes [ 0 ] ) ) ;
5757 }
5858 this . updateStripesClass ( startsWithOdd ) ;
@@ -168,8 +168,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
168168 visibleNodes : Array < ViewportDataGridNode < T > > ,
169169 offset : number ,
170170 } {
171- const nodes =
172- ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) . filter ( this . testNodeWithFilters . bind ( this ) ) ;
171+ const nodes = this . filteredNodes ( ) ;
173172
174173 if ( this . inline ) {
175174 return { topPadding : 0 , bottomPadding : 0 , contentHeight : 0 , visibleNodes : nodes , offset : 0 } ;
@@ -210,14 +209,11 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
210209 }
211210
212211 override getNumberOfRows ( ) : number {
213- return ( this . rootNode ( ) as ViewportDataGridNode < T > )
214- . flatChildren ( )
215- . filter ( this . testNodeWithFilters . bind ( this ) )
216- . length ;
212+ return this . filteredNodes ( ) . length ;
217213 }
218214
219215 private contentHeight ( ) : number {
220- const nodes = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
216+ const nodes = this . filteredNodes ( ) ;
221217 let result = 0 ;
222218 for ( let i = 0 , size = nodes . length ; i < size ; ++ i ) {
223219 result += nodes [ i ] . nodeSelfHeight ( ) ;
@@ -260,7 +256,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
260256 let offset = viewportState . offset ;
261257
262258 if ( visibleNodes . length ) {
263- const nodes = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
259+ const nodes = this . filteredNodes ( ) ;
264260 const index = nodes . indexOf ( visibleNodes [ 0 ] ) ;
265261 this . updateStripesClass ( Boolean ( index % 2 ) ) ;
266262 if ( this . keepScrollingToBottom && index !== - 1 && Boolean ( index % 2 ) !== this . firstVisibleIsStriped ) {
@@ -297,7 +293,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
297293 }
298294
299295 revealViewportNode ( node : ViewportDataGridNode < T > ) : void {
300- const nodes = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
296+ const nodes = this . filteredNodes ( ) ;
301297 const index = nodes . indexOf ( node ) ;
302298 if ( index === - 1 ) {
303299 return ;
@@ -317,6 +313,10 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
317313 }
318314 this . scrollContainer . scrollTop = scrollTop ;
319315 }
316+
317+ private filteredNodes ( ) : Array < ViewportDataGridNode < T > > {
318+ return ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) . filter ( this . testNodeWithFilters . bind ( this ) ) ;
319+ }
320320}
321321
322322export const enum Events {
0 commit comments