Skip to content

Commit 59e4cb2

Browse files
muanKristján Oddsson
andcommitted
Include upstream changes
Co-authored-by: Kristján Oddsson <[email protected]>
1 parent 87206d7 commit 59e4cb2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ class RemoteInputElement extends HTMLElement {
55
debounceInputChange: Event => void
66
boundFetchResults: Event => mixed
77

8+
static get observedAttributes() {
9+
return ['src']
10+
}
11+
12+
attributeChangedCallback(name: string) {
13+
if (name === 'src') {
14+
this.fetchResults(false)
15+
}
16+
}
17+
818
connectedCallback() {
919
const input = this.input
1020
if (!input) return
@@ -53,10 +63,10 @@ class RemoteInputElement extends HTMLElement {
5363
this.setAttribute('name', name)
5464
}
5565

56-
async fetchResults() {
66+
async fetchResults(checkCurrentQuery: boolean = true) {
5767
if (!this.input) return
5868
const query = this.input.value.trim()
59-
if (this.currentQuery === query) return
69+
if (checkCurrentQuery && this.currentQuery === query) return
6070
this.currentQuery = query
6171
const src = this.src
6272
if (!src) return
@@ -74,7 +84,7 @@ class RemoteInputElement extends HTMLElement {
7484
const html = await fetch(url).then(data => data.text())
7585
this.dispatchEvent(new CustomEvent('load'))
7686
resultsContainer.innerHTML = html
77-
} catch (err) {
87+
} catch {
7888
this.dispatchEvent(new CustomEvent('error'))
7989
}
8090
this.removeAttribute('loading')

0 commit comments

Comments
 (0)