@marianmeres/stuic 3.105.0 → 3.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -173,6 +173,15 @@ export function validate(el, fn) {
173
173
  const _doValidate = () => {
174
174
  if (!enabled)
175
175
  return;
176
+ // A focused, dirty field torn down by a route change fires a final
177
+ // synchronous `change`/`blur` while being removed from the DOM. That
178
+ // removal runs inside Svelte's flush, so writing `validation` state here
179
+ // would throw `state_unsafe_mutation`. By then the node is already
180
+ // detached (`isConnected === false`) and the field is going away — skip.
181
+ // No-op for normal interactive validation and for the synchronous
182
+ // imperative `validate()` path, both of which run while connected.
183
+ if (!el.isConnected)
184
+ return;
176
185
  el.checkValidity();
177
186
  // Store customValidator message directly - hidden inputs (type="hidden")
178
187
  // don't populate el.validationMessage even when setCustomValidity() is called.
@@ -210,9 +219,6 @@ export function validate(el, fn) {
210
219
  return m;
211
220
  }, []);
212
221
  // console.log(1111, validityState, el);
213
- // hm... Uncaught Svelte error: state_unsafe_mutation...
214
- // the `tick` await helps, but I'm not really sure I understand the internals...
215
- // tick().then(() => {
216
222
  setValidationResult?.({
217
223
  validity: validityState,
218
224
  reasons,
@@ -224,7 +230,6 @@ export function validate(el, fn) {
224
230
  el.validationMessage ||
225
231
  "This field is invalid. Please review and try again."),
226
232
  });
227
- // });
228
233
  };
229
234
  // Expose the current validator to the host so it can trigger validation
230
235
  // imperatively (e.g., on submit). The closure captures the current
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "3.105.0",
3
+ "version": "3.106.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && pnpm run prepack",