Skip to content

Commit 48b1d8e

Browse files
committed
Fixed taintOptions when returning the same form.
1 parent 9792a73 commit 48b1d8e

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Fixed client validation issue with rapid multiple blur events.
1313
- Arktype adapter improved.
1414
- Fixed union handling with default values.
15+
- When using `{ taint: 'untaint-form' }` option, form wasn't untainted unless it was modified.
1516

1617
## [2.27.0] - 2025-06-16
1718

src/lib/client/superForm.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,37 +1301,37 @@ export function superForm<
13011301
//console.log('newTainted:', JSON.stringify(newTainted));
13021302

13031303
if (paths.length) {
1304-
if (taintOptions == 'untaint-all' || taintOptions == 'untaint-form') {
1305-
Tainted.state.set(undefined);
1306-
} else {
1307-
Tainted.state.update((currentlyTainted) => {
1308-
if (!currentlyTainted) currentlyTainted = {};
1309-
1310-
setPaths(currentlyTainted, paths, (path, data) => {
1311-
// If value goes back to the clean value, untaint the path
1312-
if (!newTainted.includes(path.join())) return undefined;
1313-
1314-
const currentValue = traversePath(newData, path);
1315-
const cleanPath = traversePath(Tainted.clean, path);
1316-
const identical = currentValue && cleanPath && currentValue.value === cleanPath.value;
1317-
1318-
const output = identical
1319-
? undefined
1320-
: taintOptions === true
1321-
? true
1322-
: taintOptions === 'untaint'
1323-
? undefined
1324-
: data.value;
1325-
1326-
return output;
1327-
});
1328-
1329-
return currentlyTainted;
1304+
Tainted.state.update((currentlyTainted) => {
1305+
if (!currentlyTainted) currentlyTainted = {};
1306+
1307+
setPaths(currentlyTainted, paths, (path, data) => {
1308+
// If value goes back to the clean value, untaint the path
1309+
if (!newTainted.includes(path.join())) return undefined;
1310+
1311+
const currentValue = traversePath(newData, path);
1312+
const cleanPath = traversePath(Tainted.clean, path);
1313+
const identical = currentValue && cleanPath && currentValue.value === cleanPath.value;
1314+
1315+
const output = identical
1316+
? undefined
1317+
: taintOptions === true
1318+
? true
1319+
: taintOptions === 'untaint'
1320+
? undefined
1321+
: data.value;
1322+
1323+
return output;
13301324
});
1331-
}
1325+
1326+
return currentlyTainted;
1327+
});
13321328

13331329
NextChange_setHtmlEvent({ paths });
13341330
}
1331+
1332+
if (taintOptions == 'untaint-all' || taintOptions == 'untaint-form') {
1333+
Tainted.state.set(undefined);
1334+
}
13351335
}
13361336

13371337
/**

0 commit comments

Comments
 (0)