diff --git a/src/lib/client/index.ts b/src/lib/client/index.ts index a95f2c46..8f065093 100644 --- a/src/lib/client/index.ts +++ b/src/lib/client/index.ts @@ -744,20 +744,22 @@ export function superForm< options, - capture: () => ({ - valid: get(Valid), - errors: get(Errors), - data: get(Form), - empty: get(Empty), - constraints: get(Constraints), - message: get(Message), - id: formId, - meta: get(Meta), - tainted: get(Tainted) - }), - - restore: (snapshot: SuperFormSnapshot) => { - rebind(snapshot, snapshot.tainted ?? true); + capture: function () { + return { + valid: get(Valid), + errors: get(Errors), + data: get(Form), + empty: get(Empty), + constraints: get(Constraints), + message: get(Message), + id: formId, + meta: get(Meta), + tainted: get(Tainted) + }; + }, + + restore: function (snapshot: SuperFormSnapshot) { + return rebind(snapshot, snapshot.tainted ?? true); }, validate: (path, opts) => { diff --git a/src/routes/snapshot/+page.svelte b/src/routes/snapshot/+page.svelte index dcd6be1c..4b2f8ed2 100644 --- a/src/routes/snapshot/+page.svelte +++ b/src/routes/snapshot/+page.svelte @@ -6,6 +6,17 @@ export let data: PageData; + export const snapshot: Snapshot = { + capture: () => { + console.log('Capture', $page); + return capture(); + }, + restore: (value) => { + console.log('Restore', value, $page); + restore(value); + } + }; + const { form, errors, @@ -22,17 +33,6 @@ console.log($page.status); } }); - - export const snapshot: Snapshot = { - capture: () => { - console.log('Capture', $page); - return capture(); - }, - restore: (value) => { - console.log('Restore', value, $page); - restore(value); - } - };