@@ -5,22 +5,33 @@ export const ReactiveURLSearchParams = make_reactive(URLSearchParams, {
5
5
read_properties : [ 'get' , 'has' , 'getAll' ] ,
6
6
interceptors : {
7
7
set : ( options , ...params ) => {
8
- if ( typeof params [ 0 ] == 'string' && options . value . get ( params [ 0 ] ) === params [ 1 ] ) {
8
+ const value = options . value . get ( /**@type {string } */ ( params [ 0 ] ) ) ;
9
+ const value_has_changed = value !== /**@type {string } */ ( params [ 1 ] ) . toString ( ) ;
10
+ if ( value && ! value_has_changed ) {
9
11
return false ;
10
12
}
11
- options . notify_read_properties ( [ 'get' , 'has' , 'getAll' ] , params [ 0 ] ) ;
13
+
14
+ if ( ! value ) {
15
+ options . notify_read_properties ( [ 'has' ] , params [ 0 ] ) ;
16
+ }
17
+
18
+ if ( value_has_changed ) {
19
+ options . notify_read_properties ( [ 'get' ] , params [ 0 ] ) ;
20
+ }
21
+
22
+ options . notify_read_properties ( [ 'getAll' ] , params [ 0 ] ) ;
12
23
return true ;
13
24
} ,
14
25
append : ( options , ...params ) => {
15
26
options . notify_read_properties ( [ 'getAll' ] , params [ 0 ] ) ;
16
27
17
- if ( typeof params [ 0 ] == 'string' && ! options . value . has ( params [ 0 ] ) ) {
28
+ if ( ! options . value . has ( /** @type { string } */ ( params [ 0 ] ) ) ) {
18
29
options . notify_read_properties ( [ 'get' , 'has' ] , params [ 0 ] ) ;
19
30
}
20
31
return true ;
21
32
} ,
22
33
delete : ( options , ...params ) => {
23
- if ( typeof params [ 0 ] == 'string' && ! options . value . has ( params [ 0 ] ) ) {
34
+ if ( ! options . value . has ( /** @type { string } */ ( params [ 0 ] ) ) ) {
24
35
return false ;
25
36
}
26
37
options . notify_read_properties ( [ 'get' , 'has' , 'getAll' ] , params [ 0 ] ) ;
0 commit comments