@@ -43,40 +43,29 @@ class RemoteInputElement extends HTMLElement {
43
43
return input instanceof HTMLInputElement || input instanceof HTMLTextAreaElement ? input : null
44
44
}
45
45
46
- get resultsContainer ( ) : ?HTMLElement {
47
- return document . getElementById ( this . getAttribute ( 'aria-owns' ) || '' )
48
- }
49
-
50
46
get src ( ) : string {
51
47
return this . getAttribute ( 'src' ) || ''
52
48
}
53
49
54
50
set src ( url : string ) {
55
51
this . setAttribute ( 'src' , url )
56
52
}
57
-
58
- get name ( ) : string {
59
- return this . getAttribute ( 'name' ) || 'q'
60
- }
61
-
62
- set name ( name : string ) {
63
- this . setAttribute ( 'name' , name )
64
- }
65
53
}
66
54
67
55
async function fetchResults ( remoteInput : RemoteInputElement , checkCurrentQuery : boolean = true ) {
68
- if ( ! remoteInput . input ) return
69
- const query = remoteInput . input . value
56
+ const input = remoteInput . input
57
+ if ( ! input ) return
58
+ const query = input . value
70
59
if ( checkCurrentQuery && remoteInput . currentQuery === query ) return
71
60
remoteInput . currentQuery = query
72
61
const src = remoteInput . src
73
62
if ( ! src ) return
74
- const resultsContainer = remoteInput . resultsContainer
63
+ const resultsContainer = document . getElementById ( remoteInput . getAttribute ( 'aria-owns' ) || '' )
75
64
if ( ! resultsContainer ) return
76
65
77
66
const url = new URL ( src , window . location . origin )
78
67
const params = new URLSearchParams ( url . search )
79
- params . append ( remoteInput . name , query )
68
+ params . append ( remoteInput . getAttribute ( 'param' ) || 'q' , query )
80
69
url . search = params . toString ( )
81
70
82
71
remoteInput . dispatchEvent ( new CustomEvent ( 'loadstart' ) )
0 commit comments