Skip to content

Commit e2e2dc1

Browse files
muandgraham
andauthored
Apply suggestions from code review
empty html should be accepted Co-Authored-By: David Graham <[email protected]>
1 parent 8f5ed49 commit e2e2dc1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery:
7070

7171
remoteInput.dispatchEvent(new CustomEvent('loadstart'))
7272
remoteInput.setAttribute('loading', '')
73-
let response, html
73+
let response
74+
let html = ''
7475
try {
7576
response = await fetch(url, {
7677
credentials: 'same-origin',
@@ -79,9 +80,9 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery:
7980
html = await response.text()
8081
remoteInput.dispatchEvent(new CustomEvent('load'))
8182
} catch {
82-
// noop
83+
// Network errors handled below.
8384
}
84-
if (response && response.ok && html) {
85+
if (response && response.ok) {
8586
resultsContainer.innerHTML = html
8687
} else {
8788
remoteInput.dispatchEvent(new CustomEvent('error'))

0 commit comments

Comments
 (0)