@@ -51,8 +51,7 @@ function _empty() {}function _awaitIgnored(value, direct) {
5151 if ( ! direct ) {
5252 return value && value . then ? value . then ( _empty ) : Promise . resolve ( ) ;
5353 }
54- }
55- function _invoke ( body , then ) {
54+ } function _invoke ( body , then ) {
5655 var result = body ( ) ; if ( result && result . then ) {
5756 return result . then ( then ) ;
5857 } return then ( result ) ;
@@ -256,11 +255,13 @@ function _invoke(body, then) {
256255 return this . inputIsComponent ? '$off' : 'removeEventListener' ;
257256 } ,
258257 hoveredIndex : function hoveredIndex ( ) {
259- var _this2 = this ;
260-
261- return this . suggestions . findIndex ( function ( el ) {
262- return _this2 . hovered && _this2 . valueProperty ( _this2 . hovered ) == _this2 . valueProperty ( el ) ;
263- } ) ;
258+ for ( var i = 0 ; i < this . suggestions . length ; i ++ ) {
259+ var el = this . suggestions [ i ] ;
260+ if ( this . hovered && this . valueProperty ( this . hovered ) == this . valueProperty ( el ) ) {
261+ return i ;
262+ }
263+ }
264+ return - 1 ;
264265 } ,
265266 textLength : function textLength ( ) {
266267 return this . text && this . text . length || this . inputElement . value . length || 0 ;
@@ -329,10 +330,10 @@ function _invoke(body, then) {
329330 return true ;
330331 } ,
331332 miscSlotsAreEmpty : function miscSlotsAreEmpty ( ) {
332- var _this3 = this ;
333+ var _this2 = this ;
333334
334335 var slots = [ 'misc-item-above' , 'misc-item-below' ] . map ( function ( s ) {
335- return _this3 . $scopedSlots [ s ] ;
336+ return _this2 . $scopedSlots [ s ] ;
336337 } ) ;
337338
338339 if ( slots . every ( function ( s ) {
@@ -384,12 +385,12 @@ function _invoke(body, then) {
384385 this . setText ( this . displayProperty ( suggestion ) ) ;
385386 } ,
386387 setText : function setText ( text ) {
387- var _this4 = this ;
388+ var _this3 = this ;
388389
389390 this . $nextTick ( function ( ) {
390- _this4 . inputElement . value = text ;
391- _this4 . text = text ;
392- _this4 . $emit ( 'input' , text ) ;
391+ _this3 . inputElement . value = text ;
392+ _this3 . text = text ;
393+ _this3 . $emit ( 'input' , text ) ;
393394 } ) ;
394395 } ,
395396 select : function select ( item ) {
@@ -435,17 +436,17 @@ function _invoke(body, then) {
435436 } ,
436437 showSuggestions : function showSuggestions ( ) {
437438 try {
438- var _this6 = this ;
439+ var _this5 = this ;
439440
440441 return _invoke ( function ( ) {
441- if ( _this6 . suggestions . length === 0 && _this6 . minLength <= _this6 . textLength ) {
442+ if ( _this5 . suggestions . length === 0 && _this5 . minLength <= _this5 . textLength ) {
442443 // try show misc slots while researching
443- _this6 . showList ( ) ;
444- return _awaitIgnored ( _this6 . research ( ) ) ;
444+ _this5 . showList ( ) ;
445+ return _awaitIgnored ( _this5 . research ( ) ) ;
445446 }
446447 } , function ( ) {
447448
448- _this6 . showList ( ) ;
449+ _this5 . showList ( ) ;
449450 } ) ;
450451 } catch ( e ) {
451452 return Promise . reject ( e ) ;
@@ -524,7 +525,7 @@ function _invoke(body, then) {
524525 this . isClicking = this . isOverList = false ;
525526 } ,
526527 onBlur : function onBlur ( e ) {
527- var _this7 = this ;
528+ var _this6 = this ;
528529
529530 if ( this . isInFocus ) {
530531
@@ -540,7 +541,7 @@ function _invoke(body, then) {
540541 } else if ( e && e . isTrusted && ! this . isTabbed ) {
541542 this . isFalseFocus = true ;
542543 setTimeout ( function ( ) {
543- _this7 . inputElement . focus ( ) ;
544+ _this6 . inputElement . focus ( ) ;
544545 } , 0 ) ;
545546 }
546547 } else {
@@ -593,68 +594,68 @@ function _invoke(body, then) {
593594 } ,
594595 research : function research ( ) {
595596 try {
596- var _this9 = this ;
597+ var _this8 = this ;
597598
598599 return _finally ( function ( ) {
599600 return _catch ( function ( ) {
600601 return _invokeIgnored ( function ( ) {
601- if ( _this9 . canSend ) {
602- _this9 . canSend = false ;
602+ if ( _this8 . canSend ) {
603+ _this8 . canSend = false ;
603604 // @TODO : fix when promises will be cancelable (never :D)
604- var textBeforeRequest = _this9 . text ;
605- return _await ( _this9 . getSuggestions ( _this9 . text ) , function ( newList ) {
606- if ( textBeforeRequest === _this9 . text ) {
607- _this9 . $set ( _this9 , 'suggestions' , newList ) ;
605+ var textBeforeRequest = _this8 . text ;
606+ return _await ( _this8 . getSuggestions ( _this8 . text ) , function ( newList ) {
607+ if ( textBeforeRequest === _this8 . text ) {
608+ _this8 . $set ( _this8 , 'suggestions' , newList ) ;
608609 }
609610 } ) ;
610611 }
611612 } ) ;
612613 } , function ( e ) {
613- _this9 . clearSuggestions ( ) ;
614+ _this8 . clearSuggestions ( ) ;
614615 throw e ;
615616 } ) ;
616617 } , function ( ) {
617- _this9 . canSend = true ;
618+ _this8 . canSend = true ;
618619
619- if ( _this9 . suggestions . length === 0 && _this9 . miscSlotsAreEmpty ( ) ) {
620- _this9 . hideList ( ) ;
621- } else if ( _this9 . isInFocus ) {
622- _this9 . showList ( ) ;
620+ if ( _this8 . suggestions . length === 0 && _this8 . miscSlotsAreEmpty ( ) ) {
621+ _this8 . hideList ( ) ;
622+ } else if ( _this8 . isInFocus ) {
623+ _this8 . showList ( ) ;
623624 }
624625
625- return _this9 . suggestions ;
626+ return _this8 . suggestions ;
626627 } ) ;
627628 } catch ( e ) {
628629 return Promise . reject ( e ) ;
629630 }
630631 } ,
631632 getSuggestions : function getSuggestions ( value ) {
632633 try {
633- var _this11 = this ;
634+ var _this10 = this ;
634635
635636 value = value || '' ;
636637
637- if ( value . length < _this11 . minLength ) {
638+ if ( value . length < _this10 . minLength ) {
638639 return [ ] ;
639640 }
640641
641- _this11 . selected = null ;
642+ _this10 . selected = null ;
642643
643644 // Start request if can
644- if ( _this11 . listIsRequest ) {
645- _this11 . $emit ( 'request-start' , value ) ;
645+ if ( _this10 . listIsRequest ) {
646+ _this10 . $emit ( 'request-start' , value ) ;
646647 }
647648
648649 var result = [ ] ;
649650 return _finally ( function ( ) {
650651 return _catch ( function ( ) {
651652 return _invoke ( function ( ) {
652- if ( _this11 . listIsRequest ) {
653- return _await ( _this11 . list ( value ) , function ( _this10 $list) {
654- result = _this10 $list || [ ] ;
653+ if ( _this10 . listIsRequest ) {
654+ return _await ( _this10 . list ( value ) , function ( _this9 $list) {
655+ result = _this9 $list || [ ] ;
655656 } ) ;
656657 } else {
657- result = _this11 . list ;
658+ result = _this10 . list ;
658659 }
659660 } , function ( ) {
660661
@@ -663,28 +664,28 @@ function _invoke(body, then) {
663664 result = [ result ] ;
664665 }
665666
666- _this11 . isPlainSuggestion = _typeof ( result [ 0 ] ) !== 'object' || Array . isArray ( result [ 0 ] ) ;
667+ _this10 . isPlainSuggestion = _typeof ( result [ 0 ] ) !== 'object' || Array . isArray ( result [ 0 ] ) ;
667668
668- if ( _this11 . filterByQuery ) {
669+ if ( _this10 . filterByQuery ) {
669670 result = result . filter ( function ( el ) {
670- return _this11 . filter ( el , value ) ;
671+ return _this10 . filter ( el , value ) ;
671672 } ) ;
672673 }
673674
674- if ( _this11 . listIsRequest ) {
675- _this11 . $emit ( 'request-done' , result ) ;
675+ if ( _this10 . listIsRequest ) {
676+ _this10 . $emit ( 'request-done' , result ) ;
676677 }
677678 } ) ;
678679 } , function ( e ) {
679- if ( _this11 . listIsRequest ) {
680- _this11 . $emit ( 'request-failed' , e ) ;
680+ if ( _this10 . listIsRequest ) {
681+ _this10 . $emit ( 'request-failed' , e ) ;
681682 } else {
682683 throw e ;
683684 }
684685 } ) ;
685686 } , function ( ) {
686- if ( _this11 . maxSuggestions ) {
687- result . splice ( _this11 . maxSuggestions ) ;
687+ if ( _this10 . maxSuggestions ) {
688+ result . splice ( _this10 . maxSuggestions ) ;
688689 }
689690
690691 return result ;
0 commit comments