File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -269,10 +269,10 @@ var Dataset = (function() {
269
269
// do not render the suggestions as they've become outdated
270
270
if ( ! canceled && rendered < that . limit ) {
271
271
that . cancel = $ . noop ;
272
- that . _append ( query , suggestions . slice ( 0 , that . limit - rendered ) ) ;
273
- rendered += suggestions . length ;
274
-
275
- that . async && that . trigger ( ' asyncReceived' , query ) ;
272
+ var idx = Math . abs ( rendered - that . limit ) ;
273
+ rendered += idx ;
274
+ that . _append ( query , suggestions . slice ( 0 , idx ) ) ;
275
+ that . async && that . trigger ( " asyncReceived" , query ) ;
276
276
}
277
277
}
278
278
} ,
Original file line number Diff line number Diff line change @@ -225,6 +225,7 @@ describe('Dataset', function() {
225
225
} ) ;
226
226
227
227
it ( 'should respect limit option in regard to async' , function ( ) {
228
+ this . dataset . limit = 6 ;
228
229
this . dataset . async = true ;
229
230
this . source . andCallFake ( fakeGetWithAsyncSuggestions ) ;
230
231
@@ -233,7 +234,7 @@ describe('Dataset', function() {
233
234
waits ( 100 ) ;
234
235
235
236
runs ( function ( ) {
236
- expect ( this . dataset . $el . find ( '.tt-suggestion' ) ) . toHaveLength ( 5 ) ;
237
+ expect ( this . dataset . $el . find ( '.tt-suggestion' ) ) . toHaveLength ( 6 ) ;
237
238
} ) ;
238
239
} ) ;
239
240
You can’t perform that action at this time.
0 commit comments