File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,16 @@ class RemoteInputElement extends HTMLElement {
5
5
debounceInputChange : Event => void
6
6
boundFetchResults : Event => mixed
7
7
8
+ static get observedAttributes ( ) {
9
+ return [ 'src' ]
10
+ }
11
+
12
+ attributeChangedCallback ( name : string ) {
13
+ if ( name === 'src' ) {
14
+ this . fetchResults ( false )
15
+ }
16
+ }
17
+
8
18
connectedCallback ( ) {
9
19
const input = this . input
10
20
if ( ! input ) return
@@ -53,10 +63,10 @@ class RemoteInputElement extends HTMLElement {
53
63
this . setAttribute ( 'name' , name )
54
64
}
55
65
56
- async fetchResults ( ) {
66
+ async fetchResults ( checkCurrentQuery : boolean = true ) {
57
67
if ( ! this . input ) return
58
68
const query = this . input . value . trim ( )
59
- if ( this . currentQuery === query ) return
69
+ if ( checkCurrentQuery && this . currentQuery === query ) return
60
70
this . currentQuery = query
61
71
const src = this . src
62
72
if ( ! src ) return
@@ -74,7 +84,7 @@ class RemoteInputElement extends HTMLElement {
74
84
const html = await fetch ( url ) . then ( data => data . text ( ) )
75
85
this . dispatchEvent ( new CustomEvent ( 'load' ) )
76
86
resultsContainer . innerHTML = html
77
- } catch ( err ) {
87
+ } catch {
78
88
this . dispatchEvent ( new CustomEvent ( 'error' ) )
79
89
}
80
90
this . removeAttribute ( 'loading' )
You can’t perform that action at this time.
0 commit comments