Skip to content

Commit 5b1dea5

Browse files
committed
Posting without Javascript enabled in the browser didn't detect new validation data.
1 parent 97a6e92 commit 5b1dea5

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Headlines: Added, Changed, Deprecated, Removed, Fixed, Security
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.8.6] - 2023-05-06
9+
10+
### Fixed
11+
12+
- Posting without Javascript enabled in the browser didn't detect new validation data.
13+
814
## [0.8.5] - 2023-05-04
915

1016
### Fixed

src/lib/client/index.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ export function superForm<
335335
let _formId = typeof form === 'string' ? form : options.id ?? form?.id;
336336
const FormId = writable<string | undefined>(_formId);
337337

338+
// Detect if a form is posted without JavaScript.
339+
const postedForm = get(page).form;
340+
if (postedForm && typeof postedForm === 'object') {
341+
for (const superForm of Context_findValidationForms(
342+
postedForm
343+
).reverse()) {
344+
if (superForm.id === _formId) {
345+
form = superForm as Validation<T2, M>;
346+
break;
347+
}
348+
}
349+
}
350+
338351
// Normalize form argument to Validation<T, M>
339352
if (!form || typeof form === 'string') {
340353
form = Context_newEmptyForm(); // Takes care of null | undefined | string
@@ -716,21 +729,6 @@ export function superForm<
716729
}
717730
});
718731

719-
// Detect if a form is posted without JavaScript.
720-
{
721-
const postedForm = get(page).form;
722-
if (postedForm && typeof postedForm === 'object') {
723-
for (const superForm of Context_findValidationForms(
724-
postedForm
725-
).reverse()) {
726-
if (superForm.id === _formId) {
727-
form = superForm as Validation<T2, M>;
728-
break;
729-
}
730-
}
731-
}
732-
}
733-
734732
if (options.dataType !== 'json') {
735733
for (const [key, value] of Object.entries(form2.data)) {
736734
Form_checkForNestedData(key, value);

0 commit comments

Comments
 (0)