Fix results undefined initially in `SearchBox`

This commit is contained in:
jos 2019-09-01 16:37:29 +02:00
parent b354ddbe8d
commit 9d018c408a
1 changed files with 3 additions and 2 deletions

View File

@ -15,6 +15,7 @@ export class SearchBox {
this.timeout = undefined this.timeout = undefined
this.delay = 200 // ms this.delay = 200 // ms
this.lastText = undefined this.lastText = undefined
this.results = null
this.dom = {} this.dom = {}
this.dom.container = container this.dom.container = container
@ -90,7 +91,7 @@ export class SearchBox {
* focus is false by default. * focus is false by default.
*/ */
next (focus) { next (focus) {
if (this.results !== null) { if (this.results) {
let index = this.resultIndex !== null ? this.resultIndex + 1 : 0 let index = this.resultIndex !== null ? this.resultIndex + 1 : 0
if (index > this.results.length - 1) { if (index > this.results.length - 1) {
index = 0 index = 0
@ -105,7 +106,7 @@ export class SearchBox {
* focus is false by default. * focus is false by default.
*/ */
previous (focus) { previous (focus) {
if (this.results !== null) { if (this.results) {
const max = this.results.length - 1 const max = this.results.length - 1
let index = this.resultIndex !== null ? this.resultIndex - 1 : max let index = this.resultIndex !== null ? this.resultIndex - 1 : max
if (index < 0) { if (index < 0) {