@@ -17,20 +17,17 @@ export class ListCollection<T> implements Collection<Node<T>> {
1717 private iterable : Iterable < Node < T > > ;
1818 private firstKey : Key | null = null ;
1919 private lastKey : Key | null = null ;
20+ private _size : number ;
2021
2122 constructor ( nodes : Iterable < Node < T > > ) {
2223 this . iterable = nodes ;
2324
2425 let visit = ( node : Node < T > ) => {
25- // Skip the loader node so it isn't added to the keymap and thus
26- // doesn't influence the size count. This should only matter for RAC and S2
27- if ( node . type !== 'loader' ) {
28- this . keyMap . set ( node . key , node ) ;
29-
30- if ( node . childNodes && node . type === 'section' ) {
31- for ( let child of node . childNodes ) {
32- visit ( child ) ;
33- }
26+ this . keyMap . set ( node . key , node ) ;
27+
28+ if ( node . childNodes && node . type === 'section' ) {
29+ for ( let child of node . childNodes ) {
30+ visit ( child ) ;
3431 }
3532 }
3633 } ;
@@ -41,6 +38,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
4138
4239 let last : Node < T > | null = null ;
4340 let index = 0 ;
41+ let size = 0 ;
4442 for ( let [ key , node ] of this . keyMap ) {
4543 if ( last ) {
4644 last . nextKey = key ;
@@ -54,13 +52,19 @@ export class ListCollection<T> implements Collection<Node<T>> {
5452 node . index = index ++ ;
5553 }
5654
55+ // Only count sections and items when determining size so that
56+ // loaders and separators in RAC/S2 don't influence the emptyState determination
57+ if ( node . type === 'section' || node . type === 'item' ) {
58+ size ++ ;
59+ }
60+
5761 last = node ;
5862
5963 // Set nextKey as undefined since this might be the last node
6064 // If it isn't the last node, last.nextKey will properly set at start of new loop
6165 last . nextKey = undefined ;
6266 }
63-
67+ this . _size = size ;
6468 this . lastKey = last ?. key ?? null ;
6569 }
6670
@@ -69,7 +73,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
6973 }
7074
7175 get size ( ) : number {
72- return this . keyMap . size ;
76+ return this . _size ;
7377 }
7478
7579 getKeys ( ) : IterableIterator < Key > {
0 commit comments