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() {
269269 // do not render the suggestions as they've become outdated
270270 if ( ! canceled && rendered < that . limit ) {
271271 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 ) ;
276276 }
277277 }
278278 } ,
Original file line number Diff line number Diff line change @@ -225,6 +225,7 @@ describe('Dataset', function() {
225225 } ) ;
226226
227227 it ( 'should respect limit option in regard to async' , function ( ) {
228+ this . dataset . limit = 6 ;
228229 this . dataset . async = true ;
229230 this . source . andCallFake ( fakeGetWithAsyncSuggestions ) ;
230231
@@ -233,7 +234,7 @@ describe('Dataset', function() {
233234 waits ( 100 ) ;
234235
235236 runs ( function ( ) {
236- expect ( this . dataset . $el . find ( '.tt-suggestion' ) ) . toHaveLength ( 5 ) ;
237+ expect ( this . dataset . $el . find ( '.tt-suggestion' ) ) . toHaveLength ( 6 ) ;
237238 } ) ;
238239 } ) ;
239240
You can’t perform that action at this time.
0 commit comments