@@ -88,7 +88,7 @@ define([
88
88
}
89
89
90
90
setTimeout ( $ . proxy ( function ( ) {
91
- if ( this . autoComplete . css ( 'display' , 'none ') ) {
91
+ if ( this . autoComplete . is ( ':hidden ') ) {
92
92
this . setActiveState ( false ) ;
93
93
} else {
94
94
this . element . trigger ( 'focus' ) ;
@@ -288,44 +288,46 @@ define([
288
288
} , $ . proxy ( function ( data ) {
289
289
$ . each ( data , function ( index , element ) {
290
290
var html ;
291
-
292
291
element . index = index ;
293
292
html = template ( {
294
293
data : element
295
294
} ) ;
296
295
dropdown . append ( html ) ;
297
296
} ) ;
298
- this . responseList . indexList = this . autoComplete . html ( dropdown )
299
- . css ( clonePosition )
300
- . show ( )
301
- . find ( this . options . responseFieldElements + ':visible' ) ;
302
297
303
- this . _resetResponseList ( false ) ;
304
- this . element . removeAttr ( 'aria-activedescendant' ) ;
298
+ if ( dropdown . has ( 'li' ) . length ) {
299
+ this . responseList . indexList = this . autoComplete . html ( dropdown )
300
+ . css ( clonePosition )
301
+ . show ( )
302
+ . find ( this . options . responseFieldElements + ':visible' ) ;
305
303
306
- if ( this . responseList . indexList . length ) {
307
- this . _updateAriaHasPopup ( true ) ;
308
- } else {
309
- this . _updateAriaHasPopup ( false ) ;
310
- }
304
+ this . _resetResponseList ( false ) ;
305
+ this . element . removeAttr ( 'aria-activedescendant' ) ;
311
306
312
- this . responseList . indexList
313
- . on ( 'click' , function ( e ) {
314
- this . responseList . selected = $ ( e . currentTarget ) ;
315
- this . searchForm . trigger ( 'submit' ) ;
316
- } . bind ( this ) )
317
- . on ( 'mouseenter mouseleave' , function ( e ) {
318
- this . responseList . indexList . removeClass ( this . options . selectClass ) ;
319
- $ ( e . target ) . addClass ( this . options . selectClass ) ;
320
- this . responseList . selected = $ ( e . target ) ;
321
- this . element . attr ( 'aria-activedescendant' , $ ( e . target ) . attr ( 'id' ) ) ;
322
- } . bind ( this ) )
323
- . on ( 'mouseout' , function ( e ) {
324
- if ( ! this . _getLastElement ( ) && this . _getLastElement ( ) . hasClass ( this . options . selectClass ) ) {
325
- $ ( e . target ) . removeClass ( this . options . selectClass ) ;
326
- this . _resetResponseList ( false ) ;
327
- }
328
- } . bind ( this ) ) ;
307
+ if ( this . responseList . indexList . length ) {
308
+ this . _updateAriaHasPopup ( true ) ;
309
+ } else {
310
+ this . _updateAriaHasPopup ( false ) ;
311
+ }
312
+
313
+ this . responseList . indexList
314
+ . on ( 'click' , function ( e ) {
315
+ this . responseList . selected = $ ( e . currentTarget ) ;
316
+ this . searchForm . trigger ( 'submit' ) ;
317
+ } . bind ( this ) )
318
+ . on ( 'mouseenter mouseleave' , function ( e ) {
319
+ this . responseList . indexList . removeClass ( this . options . selectClass ) ;
320
+ $ ( e . target ) . addClass ( this . options . selectClass ) ;
321
+ this . responseList . selected = $ ( e . target ) ;
322
+ this . element . attr ( 'aria-activedescendant' , $ ( e . target ) . attr ( 'id' ) ) ;
323
+ } . bind ( this ) )
324
+ . on ( 'mouseout' , function ( e ) {
325
+ if ( ! this . _getLastElement ( ) && this . _getLastElement ( ) . hasClass ( this . options . selectClass ) ) {
326
+ $ ( e . target ) . removeClass ( this . options . selectClass ) ;
327
+ this . _resetResponseList ( false ) ;
328
+ }
329
+ } . bind ( this ) ) ;
330
+ }
329
331
} , this ) ) ;
330
332
} else {
331
333
this . _resetResponseList ( true ) ;
0 commit comments