Skip to content

Commit d268021

Browse files
committed
async attribute for link
1 parent 3f9a332 commit d268021

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

packages/react/src/Link.ts

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface BaseInertiaLinkProps {
3232
onSuccess?: () => void
3333
onError?: () => void
3434
queryStringArrayFormat?: 'indices' | 'brackets'
35+
async: boolean
3536
}
3637

3738
export type InertiaLinkProps = BaseInertiaLinkProps &
@@ -53,6 +54,7 @@ const Link = forwardRef<unknown, InertiaLinkProps>(
5354
except = [],
5455
headers = {},
5556
queryStringArrayFormat = 'brackets',
57+
async = false,
5658
onClick = noop,
5759
onCancelToken = noop,
5860
onBefore = noop,
@@ -82,6 +84,7 @@ const Link = forwardRef<unknown, InertiaLinkProps>(
8284
only,
8385
except,
8486
headers,
87+
async,
8588
onCancelToken,
8689
onBefore,
8790
onStart,
@@ -103,6 +106,7 @@ const Link = forwardRef<unknown, InertiaLinkProps>(
103106
only,
104107
except,
105108
headers,
109+
async,
106110
onClick,
107111
onCancelToken,
108112
onBefore,

packages/svelte/src/lib/components/Link.svelte

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
export let except: string[] = []
1515
export let headers: Record<string, string> = {}
1616
export let queryStringArrayFormat: 'brackets' | 'indices' = 'brackets'
17+
export let async: boolean = false
1718
1819
beforeUpdate(() => {
1920
if (as === 'a' && method.toLowerCase() !== 'get') {
@@ -38,6 +39,7 @@
3839
except,
3940
headers,
4041
queryStringArrayFormat,
42+
async,
4143
}}
4244
{...as === 'a' ? { href } : {}}
4345
{...$$restProps}

packages/vue2/src/link.ts

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface InertiaLinkProps {
2929
onCancel?: () => void
3030
onSuccess?: () => void
3131
queryStringArrayFormat?: 'brackets' | 'indices'
32+
async: boolean
3233
}
3334

3435
type InertiaLink = FunctionalComponentOptions<InertiaLinkProps>
@@ -79,6 +80,10 @@ const Link: InertiaLink = {
7980
type: String as PropType<'brackets' | 'indices'>,
8081
default: 'brackets',
8182
},
83+
async: {
84+
type: Boolean,
85+
default: false,
86+
},
8287
},
8388
render(h, { props, data, children }) {
8489
data.on = {
@@ -134,6 +139,7 @@ const Link: InertiaLink = {
134139
only: props.only,
135140
except: props.except,
136141
headers: props.headers,
142+
async: props.async,
137143
// @ts-expect-error
138144
onCancelToken: data.on.cancelToken,
139145
// @ts-expect-error

packages/vue3/src/link.ts

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface InertiaLinkProps {
2121
onCancel?: () => void
2222
onSuccess?: () => void
2323
queryStringArrayFormat?: 'brackets' | 'indices'
24+
async: boolean
2425
}
2526

2627
type InertiaLink = DefineComponent<InertiaLinkProps>
@@ -72,6 +73,10 @@ const Link: InertiaLink = defineComponent({
7273
type: String as PropType<'brackets' | 'indices'>,
7374
default: 'brackets',
7475
},
76+
async: {
77+
type: Boolean,
78+
default: false,
79+
},
7580
},
7681
setup(props, { slots, attrs }) {
7782
return () => {
@@ -103,6 +108,7 @@ const Link: InertiaLink = defineComponent({
103108
only: props.only,
104109
except: props.except,
105110
headers: props.headers,
111+
async: props.async,
106112
// @ts-expect-error
107113
onCancelToken: attrs.onCancelToken || (() => ({})),
108114
// @ts-expect-error

0 commit comments

Comments
 (0)