File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery:
71
71
remoteInput . dispatchEvent ( new CustomEvent ( 'loadstart' ) )
72
72
remoteInput . setAttribute ( 'loading' , '' )
73
73
let response
74
+ let errored = false
74
75
let html = ''
75
76
try {
76
77
response = await fetch ( url , {
@@ -80,15 +81,19 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery:
80
81
html = await response . text ( )
81
82
remoteInput . dispatchEvent ( new CustomEvent ( 'load' ) )
82
83
} catch {
83
- // Network errors handled below.
84
+ errored = true
85
+ remoteInput . dispatchEvent ( new CustomEvent ( 'error' ) )
84
86
}
87
+ remoteInput . removeAttribute ( 'loading' )
88
+ if ( errored ) return
89
+
85
90
if ( response && response . ok ) {
91
+ remoteInput . dispatchEvent ( new CustomEvent ( 'remote-input-success' , { bubbles : true } ) )
86
92
resultsContainer . innerHTML = html
87
93
} else {
88
- remoteInput . dispatchEvent ( new CustomEvent ( 'error' ) )
94
+ remoteInput . dispatchEvent ( new CustomEvent ( 'remote-input- error' , { bubbles : true } ) )
89
95
}
90
96
91
- remoteInput . removeAttribute ( 'loading' )
92
97
remoteInput . dispatchEvent ( new CustomEvent ( 'loadend' ) )
93
98
}
94
99
You can’t perform that action at this time.
0 commit comments