svelte 5.56.7 → 5.56.8

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "svelte",
3
3
  "description": "Cybernetically enhanced web apps",
4
4
  "license": "MIT",
5
- "version": "5.56.7",
5
+ "version": "5.56.8",
6
6
  "type": "module",
7
7
  "types": "./types/index.d.ts",
8
8
  "engines": {
@@ -199,17 +199,68 @@ export class Boundary {
199
199
  */
200
200
  #hydrate_failed_content(error) {
201
201
  const failed = this.#props.failed;
202
+ const { reset, invoke_onerror } = this.#create_reset(error);
203
+
204
+ // `onerror` may mutate state, which is disallowed while hydrating
205
+ queue_micro_task(invoke_onerror);
206
+
202
207
  if (!failed) return;
203
208
 
204
209
  this.#failed_effect = branch(() => {
205
210
  failed(
206
211
  this.#anchor,
207
212
  () => error,
208
- () => () => {}
213
+ () => reset
209
214
  );
210
215
  });
211
216
  }
212
217
 
218
+ /**
219
+ * Creates the `reset` function for a failed boundary, along with a function
220
+ * that invokes `onerror` with it (if provided)
221
+ * @param {unknown} error
222
+ * @returns {{ reset: () => void, invoke_onerror: () => void }}
223
+ */
224
+ #create_reset(error) {
225
+ var did_reset = false;
226
+ var calling_on_error = false;
227
+
228
+ const reset = () => {
229
+ if (did_reset) {
230
+ w.svelte_boundary_reset_noop();
231
+ return;
232
+ }
233
+
234
+ did_reset = true;
235
+
236
+ if (calling_on_error) {
237
+ e.svelte_boundary_reset_onerror();
238
+ }
239
+
240
+ if (this.#failed_effect !== null) {
241
+ pause_effect(this.#failed_effect, () => {
242
+ this.#failed_effect = null;
243
+ });
244
+ }
245
+
246
+ this.#run(() => {
247
+ this.#render();
248
+ });
249
+ };
250
+
251
+ const invoke_onerror = () => {
252
+ try {
253
+ calling_on_error = true;
254
+ this.#props.onerror?.(error, reset);
255
+ calling_on_error = false;
256
+ } catch (err) {
257
+ invoke_error_boundary(err, this.#effect && this.#effect.parent);
258
+ }
259
+ };
260
+
261
+ return { reset, invoke_onerror };
262
+ }
263
+
213
264
  #hydrate_pending_content() {
214
265
  const pending = this.#props.pending;
215
266
  if (!pending) return;
@@ -429,43 +480,13 @@ export class Boundary {
429
480
  set_hydrate_node(skip_nodes());
430
481
  }
431
482
 
432
- var onerror = this.#props.onerror;
433
483
  let failed = this.#props.failed;
434
- var did_reset = false;
435
- var calling_on_error = false;
436
-
437
- const reset = () => {
438
- if (did_reset) {
439
- w.svelte_boundary_reset_noop();
440
- return;
441
- }
442
-
443
- did_reset = true;
444
-
445
- if (calling_on_error) {
446
- e.svelte_boundary_reset_onerror();
447
- }
448
-
449
- if (this.#failed_effect !== null) {
450
- pause_effect(this.#failed_effect, () => {
451
- this.#failed_effect = null;
452
- });
453
- }
454
-
455
- this.#run(() => {
456
- this.#render();
457
- });
458
- };
459
484
 
460
485
  /** @param {unknown} transformed_error */
461
486
  const handle_error_result = (transformed_error) => {
462
- try {
463
- calling_on_error = true;
464
- onerror?.(transformed_error, reset);
465
- calling_on_error = false;
466
- } catch (error) {
467
- invoke_error_boundary(error, this.#effect && this.#effect.parent);
468
- }
487
+ const { reset, invoke_onerror } = this.#create_reset(transformed_error);
488
+
489
+ invoke_onerror();
469
490
 
470
491
  if (failed) {
471
492
  this.#failed_effect = this.#run(() => {
@@ -56,8 +56,10 @@ export function select_option(select, value, mounting = false) {
56
56
  */
57
57
  export function init_select(select) {
58
58
  var observer = new MutationObserver(() => {
59
- // @ts-ignore
60
- select_option(select, select.__value);
59
+ if ('__value' in select) {
60
+ // @ts-ignore
61
+ select_option(select, select.__value);
62
+ }
61
63
  // Deliberately don't update the potential binding value,
62
64
  // the model should be preserved unless explicitly changed
63
65
  });
package/src/version.js CHANGED
@@ -4,5 +4,5 @@
4
4
  * The current version, as set in package.json.
5
5
  * @type {string}
6
6
  */
7
- export const VERSION = '5.56.7';
7
+ export const VERSION = '5.56.8';
8
8
  export const PUBLIC_VERSION = '5';