@@ -424,6 +424,7 @@ export function superForm<
424424 }
425425
426426 if ( typeof options . SPA === 'string' ) {
427+ // SPA action mode is "passive", no page updates are made.
427428 if ( options . invalidateAll === undefined ) options . invalidateAll = false ;
428429 if ( options . applyAction === undefined ) options . applyAction = false ;
429430 }
@@ -435,7 +436,10 @@ export function superForm<
435436 ...options
436437 } ;
437438
438- if ( options . SPA === true && options . validators === undefined ) {
439+ if (
440+ ( options . SPA === true || typeof options . SPA === 'object' ) &&
441+ options . validators === undefined
442+ ) {
439443 console . warn (
440444 'No validators set for superForm in SPA mode. ' +
441445 'Add a validation adapter to the validators option, or set it to false to disable this warning.'
@@ -642,6 +646,10 @@ export function superForm<
642646 }
643647 } ;
644648
649+ function Form_isSPA ( ) {
650+ return options . SPA === true || typeof options . SPA === 'object' ;
651+ }
652+
645653 async function Form_validate (
646654 opts : {
647655 adapter ?: FormOptions < T , M > [ 'validators' ] ;
@@ -1585,7 +1593,7 @@ export function superForm<
15851593 if ( ! cancelled ) {
15861594 // Client validation
15871595 const noValidate =
1588- ! options . SPA &&
1596+ ! Form_isSPA ( ) &&
15891597 ( FormElement . noValidate ||
15901598 ( ( submit . submitter instanceof HTMLButtonElement ||
15911599 submit . submitter instanceof HTMLInputElement ) &&
@@ -1638,7 +1646,7 @@ export function superForm<
16381646 // and accidentally removing errors set by setError
16391647 lastInputChange = undefined ;
16401648
1641- if ( options . SPA === true ) {
1649+ if ( Form_isSPA ( ) ) {
16421650 if ( ! validation ) validation = await validateForm ( ) ;
16431651 cancel ( { resetTimers : false } ) ;
16441652 clientValidationResult ( validation ) ;
@@ -1692,29 +1700,6 @@ export function superForm<
16921700 if ( typeof options . SPA === 'string' ) {
16931701 ActionForm_setAction ( options . SPA ) ;
16941702 }
1695-
1696- /*
1697- if (typeof options.SPA === 'string') {
1698- const absolute = /^(?:\/\/[a-z+]+:)/i.test(options.SPA);
1699- if (!absolute) {
1700- const split = options.SPA.indexOf('?');
1701- if (split == -1) {
1702- submitParams.action.pathname = options.SPA;
1703- } else if (split == 0) {
1704- submitParams.action.search = options.SPA;
1705- } else {
1706- submitParams.action.pathname = options.SPA.slice(0, split);
1707- submitParams.action.search = options.SPA.slice(split);
1708- }
1709- }
1710-
1711- console.log(
1712- 'SPA submit to',
1713- submitParams.action.toString(),
1714- Array.from(submitData.entries())
1715- );
1716- }
1717- */
17181703 }
17191704 }
17201705
@@ -1755,7 +1740,7 @@ export function superForm<
17551740 } ;
17561741
17571742 const unsubCheckforNav =
1758- STORYBOOK_MODE || ! options . SPA
1743+ STORYBOOK_MODE || ! Form_isSPA ( )
17591744 ? ( ) => { }
17601745 : navigating . subscribe ( ( $nav ) => {
17611746 // Check for goto to a different route in the events
0 commit comments