@@ -189,17 +189,47 @@ export class DataGridModel extends DOMWidgetModel {
189189
190190 this . synchingWithKernel = true ;
191191
192- const selectionIter = sender . selections ( ) ;
193192 const selections : any [ ] = [ ] ;
194- let selectionNode = null ;
195- while ( ( selectionNode = selectionIter . next ( ) ) ) {
196- const selection = selectionNode . value ;
197- selections . push ( {
198- r1 : Math . min ( selection . r1 , selection . r2 ) ,
199- r2 : Math . max ( selection . r1 , selection . r2 ) ,
200- c1 : Math . min ( selection . c1 , selection . c2 ) ,
201- c2 : Math . max ( selection . c1 , selection . c2 ) ,
202- } ) ;
193+
194+ let selectionIter = sender . selections ( ) ;
195+ // @ts -ignore
196+ if ( typeof selectionIter . iter === 'function' ) {
197+ // Lumino 1 (JupyterLab 3)
198+ let selection = null ;
199+
200+ // @ts -ignore
201+ selectionIter = selectionIter . iter ( )
202+
203+ while ( ( selection = selectionIter . next ( ) ) ) {
204+ selections . push ( {
205+ // @ts -ignore
206+ r1 : Math . min ( selection . r1 , selection . r2 ) ,
207+ // @ts -ignore
208+ r2 : Math . max ( selection . r1 , selection . r2 ) ,
209+ // @ts -ignore
210+ c1 : Math . min ( selection . c1 , selection . c2 ) ,
211+ // @ts -ignore
212+ c2 : Math . max ( selection . c1 , selection . c2 ) ,
213+ } ) ;
214+ }
215+ } else {
216+ // Lumino 2 (JupyterLab 4)
217+ let selectionNode = null ;
218+
219+ while ( selectionNode = selectionIter . next ( ) ) {
220+ if ( selectionNode . done ) {
221+ break ;
222+ }
223+
224+ const selection = selectionNode . value ;
225+
226+ selections . push ( {
227+ r1 : Math . min ( selection . r1 , selection . r2 ) ,
228+ r2 : Math . max ( selection . r1 , selection . r2 ) ,
229+ c1 : Math . min ( selection . c1 , selection . c2 ) ,
230+ c2 : Math . max ( selection . c1 , selection . c2 ) ,
231+ } ) ;
232+ }
203233 }
204234
205235 this . set ( 'selections' , selections ) ;
0 commit comments