Skip to content

Commit 671fccd

Browse files
committed
use function for capture/restore instead of arrow function
1 parent bb02e31 commit 671fccd

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

src/lib/client/index.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -744,20 +744,22 @@ export function superForm<
744744

745745
options,
746746

747-
capture: () => ({
748-
valid: get(Valid),
749-
errors: get(Errors),
750-
data: get(Form),
751-
empty: get(Empty),
752-
constraints: get(Constraints),
753-
message: get(Message),
754-
id: formId,
755-
meta: get(Meta),
756-
tainted: get(Tainted)
757-
}),
758-
759-
restore: (snapshot: SuperFormSnapshot<T2, M>) => {
760-
rebind(snapshot, snapshot.tainted ?? true);
747+
capture: function () {
748+
return {
749+
valid: get(Valid),
750+
errors: get(Errors),
751+
data: get(Form),
752+
empty: get(Empty),
753+
constraints: get(Constraints),
754+
message: get(Message),
755+
id: formId,
756+
meta: get(Meta),
757+
tainted: get(Tainted)
758+
};
759+
},
760+
761+
restore: function (snapshot: SuperFormSnapshot<T2, M>) {
762+
return rebind(snapshot, snapshot.tainted ?? true);
761763
},
762764

763765
validate: (path, opts) => {

src/routes/snapshot/+page.svelte

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
77
export let data: PageData;
88
9+
export const snapshot: Snapshot = {
10+
capture: () => {
11+
console.log('Capture', $page);
12+
return capture();
13+
},
14+
restore: (value) => {
15+
console.log('Restore', value, $page);
16+
restore(value);
17+
}
18+
};
19+
920
const {
1021
form,
1122
errors,
@@ -22,17 +33,6 @@
2233
console.log($page.status);
2334
}
2435
});
25-
26-
export const snapshot: Snapshot = {
27-
capture: () => {
28-
console.log('Capture', $page);
29-
return capture();
30-
},
31-
restore: (value) => {
32-
console.log('Restore', value, $page);
33-
restore(value);
34-
}
35-
};
3636
</script>
3737

3838
<SuperDebug data={{ $form, capture: capture() }} />

0 commit comments

Comments
 (0)