@@ -14,7 +14,11 @@ type PrefetchLinkConfig = {
1414 cacheFor ?: number | string | ( number | string ) [ ]
1515}
1616
17- export const link : Action < HTMLElement , RouterRequestConfig & PrefetchLinkConfig > = ( node , options = { } ) => {
17+ export const link : Action < HTMLElement , RouterRequestConfig & PrefetchLinkConfig | boolean > = ( node , options = true ) => {
18+ if ( options === true ) {
19+ options = { }
20+ }
21+
1822 function mergeOptions ( options : RouterRequestConfig & PrefetchLinkConfig ) : { options : RouterRequestConfig } & PrefetchLinkConfig {
1923 options . method = options . method || 'get'
2024 options . url = options . url || ( node as HTMLAnchorElement ) . href || ''
@@ -46,7 +50,7 @@ export const link: Action<HTMLElement, RouterRequestConfig & PrefetchLinkConfig>
4650
4751 function navigate ( event ) {
4852 event . preventDefault ( )
49- axios . request ( options )
53+ axios . request ( options as RouterRequestConfig & PrefetchLinkConfig )
5054 }
5155
5256 const prefetch = ( ) => axios . request ( { ...options , prefetch : config . cacheFor } )
@@ -81,14 +85,18 @@ export const link: Action<HTMLElement, RouterRequestConfig & PrefetchLinkConfig>
8185 }
8286 }
8387
84- let config = mergeOptions ( options )
88+ let config = mergeOptions ( options as RouterRequestConfig & PrefetchLinkConfig )
8589 reinstallPrefetchEvents ( )
8690
8791 node . addEventListener ( 'click' , navigate )
8892
8993 return {
9094 update ( newOptions ) {
91- config = mergeOptions ( newOptions )
95+ if ( newOptions === true ) {
96+ newOptions = { }
97+ }
98+
99+ config = mergeOptions ( newOptions as RouterRequestConfig & PrefetchLinkConfig )
92100 reinstallPrefetchEvents ( )
93101 } ,
94102 destroy ( ) {
@@ -98,16 +106,16 @@ export const link: Action<HTMLElement, RouterRequestConfig & PrefetchLinkConfig>
98106}
99107
100108type VisibleConfig = {
101- vortex : VortexConfig ,
109+ vortex : VortexConfig | boolean ,
102110 buffer ?: number ,
103111 always ?: boolean ,
104112}
105113
106- export const visible : Action < HTMLElement , VisibleConfig | VortexConfig > = ( node , rawOptions ) => {
107- function mergeOptions ( options : VisibleConfig | VortexConfig ) : VisibleConfig {
108- return ! options . vortex
109- ? { buffer : 0 , always : false , vortex : options }
110- : { buffer : 0 , always : false , ...options as VisibleConfig }
114+ export const visible : Action < HTMLElement , VisibleConfig | VortexConfig | boolean > = ( node , rawOptions = true ) => {
115+ function mergeOptions ( options : VisibleConfig | VortexConfig | boolean ) : VisibleConfig {
116+ return options === true || ! ( options as VortexConfig ) . vortex
117+ ? { buffer : 0 , always : true , vortex : options }
118+ : { buffer : 0 , always : true , ...options as VisibleConfig }
111119 }
112120
113121 let options : VisibleConfig = mergeOptions ( rawOptions )
0 commit comments