Skip to content

Commit 2facb94

Browse files
authored
Merge branch 'main' into derived-reactivity-loss-fix
2 parents c141887 + 7a24354 commit 2facb94

File tree

11 files changed

+84
-15
lines changed

11 files changed

+84
-15
lines changed

.changeset/legal-mangos-peel.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/svelte/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# svelte
22

3+
## 5.43.3
4+
5+
### Patch Changes
6+
7+
- fix: ensure fork always accesses correct values ([#17098](https://github.com/sveltejs/svelte/pull/17098))
8+
9+
- fix: change title only after any pending work has completed ([#17061](https://github.com/sveltejs/svelte/pull/17061))
10+
11+
- fix: preserve symbols when creating derived rest properties ([#17096](https://github.com/sveltejs/svelte/pull/17096))
12+
313
## 5.43.2
414

515
### Patch Changes

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svelte",
33
"description": "Cybernetically enhanced web apps",
44
"license": "MIT",
5-
"version": "5.43.2",
5+
"version": "5.43.3",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/src/internal/client/reactivity/batch.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
DERIVED,
1616
BOUNDARY_EFFECT,
1717
EAGER_EFFECT,
18-
HEAD_EFFECT
18+
HEAD_EFFECT,
19+
ERROR_VALUE
1920
} from '#client/constants';
2021
import { async_mode_flag } from '../../flags/index.js';
2122
import { deferred, define_property } from '../../shared/utils.js';
@@ -285,12 +286,16 @@ export class Batch {
285286
this.previous.set(source, value);
286287
}
287288

288-
this.current.set(source, source.v);
289-
batch_values?.set(source, source.v);
289+
// Don't save errors in `batch_values`, or they won't be thrown in `runtime.js#get`
290+
if ((source.f & ERROR_VALUE) === 0) {
291+
this.current.set(source, source.v);
292+
batch_values?.set(source, source.v);
293+
}
290294
}
291295

292296
activate() {
293297
current_batch = this;
298+
this.apply();
294299
}
295300

296301
deactivate() {
@@ -492,7 +497,7 @@ export class Batch {
492497
}
493498

494499
apply() {
495-
if (!async_mode_flag || batches.size === 1) return;
500+
if (!async_mode_flag || (!this.is_fork && batches.size === 1)) return;
496501

497502
// if there are multiple batches, we are 'time travelling' —
498503
// we need to override values with the ones in this batch...

packages/svelte/src/internal/client/runtime.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -773,12 +773,12 @@ export function set_signal_status(signal, status) {
773773
}
774774

775775
/**
776-
* @param {Record<string, unknown>} obj
777-
* @param {string[]} keys
778-
* @returns {Record<string, unknown>}
776+
* @param {Record<string | symbol, unknown>} obj
777+
* @param {Array<string | symbol>} keys
778+
* @returns {Record<string | symbol, unknown>}
779779
*/
780780
export function exclude_from_object(obj, keys) {
781-
/** @type {Record<string, unknown>} */
781+
/** @type {Record<string | symbol, unknown>} */
782782
var result = {};
783783

784784
for (var key in obj) {
@@ -787,6 +787,12 @@ export function exclude_from_object(obj, keys) {
787787
}
788788
}
789789

790+
for (var symbol of Object.getOwnPropertySymbols(obj)) {
791+
if (Object.propertyIsEnumerable.call(obj, symbol) && !keys.includes(symbol)) {
792+
result[symbol] = obj[symbol];
793+
}
794+
}
795+
790796
return result;
791797
}
792798

packages/svelte/src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
* The current version, as set in package.json.
55
* @type {string}
66
*/
7-
export const VERSION = '5.43.2';
7+
export const VERSION = '5.43.3';
88
export const PUBLIC_VERSION = '5';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>
2+
let { x } = $props();
3+
console.log(x);
4+
await Promise.resolve();
5+
console.log(x);
6+
</script>
7+
8+
{x}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
async test({ assert, target, logs }) {
5+
const btn = target.querySelector('button');
6+
7+
btn?.click();
8+
await new Promise((r) => setTimeout(r, 2));
9+
assert.htmlEqual(target.innerHTML, `<button>fork</button> universe`);
10+
assert.deepEqual(logs, ['universe', 'universe']);
11+
}
12+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
import { fork } from 'svelte';
3+
import Child from './Child.svelte';
4+
let x = $state('world');
5+
</script>
6+
7+
<button onclick={async () => {
8+
const f = fork(() => {
9+
x = 'universe'
10+
});
11+
await new Promise(r => setTimeout(r));
12+
f.commit();
13+
}}>fork</button>
14+
15+
{#if x === 'universe'}
16+
<Child {x} />
17+
{/if}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: `<p>true false</p>`
5+
});

0 commit comments

Comments
 (0)