(
result: AutocompleteResponse,
originalQuery: string,
cacheKey: string
)
| 643 | } |
| 644 | |
| 645 | private processResponse( |
| 646 | result: AutocompleteResponse, |
| 647 | originalQuery: string, |
| 648 | cacheKey: string |
| 649 | ): void { |
| 650 | const options = this.options; |
| 651 | result.suggestions = this.verifySuggestionsFormat(result.suggestions); |
| 652 | |
| 653 | if (!options.noCache) { |
| 654 | this.cachedResponse[cacheKey] = result; |
| 655 | // Guard against pushing an empty `originalQuery`. `isBadQuery` |
| 656 | // matches by prefix (`q.indexOf(bad) === 0`); an empty entry |
| 657 | // would match every subsequent query and silently block all |
| 658 | // ajax requests after the first empty-query response. |
| 659 | if (options.preventBadQueries && !result.suggestions.length && originalQuery) { |
| 660 | this.badQueries.push(originalQuery); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | if (originalQuery !== this.getQuery(this.currentValue)) { |
| 665 | return; |
| 666 | } |
| 667 | |
| 668 | this.suggestions = result.suggestions; |
| 669 | this.suggest(); |
| 670 | } |
| 671 | |
| 672 | private activate(index: number): HTMLElement | null { |
| 673 | const selected = this.classes.selected; |
no test coverage detected