Merge branch 'main' into each-outros

pull/17258/head
Rich Harris 4 days ago
commit 4dd47155cf

@ -1,5 +0,0 @@
---
'svelte': patch
---
chore: move DOM-related effect properties to `effect.nodes`

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: allow `$props.id()` to occur after an `await`

@ -1,5 +1,15 @@
# svelte
## 5.45.4
### Patch Changes
- chore: move DOM-related effect properties to `effect.nodes` ([#17293](https://github.com/sveltejs/svelte/pull/17293))
- fix: allow `$props.id()` to occur after an `await` ([#17285](https://github.com/sveltejs/svelte/pull/17285))
- fix: keep reactions up to date even when read outside of effect ([#17295](https://github.com/sveltejs/svelte/pull/17295))
## 5.45.3
### Patch Changes

@ -2,7 +2,7 @@
"name": "svelte",
"description": "Cybernetically enhanced web apps",
"license": "MIT",
"version": "5.45.3",
"version": "5.45.4",
"type": "module",
"types": "./types/index.d.ts",
"engines": {

@ -278,7 +278,7 @@ export function update_reaction(reaction) {
reaction.deps = deps = new_deps;
}
if (is_updating_effect && effect_tracking() && (reaction.f & CONNECTED) !== 0) {
if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
for (i = skipped_deps; i < deps.length; i++) {
(deps[i].reactions ??= []).push(reaction);
}

@ -4,5 +4,5 @@
* The current version, as set in package.json.
* @type {string}
*/
export const VERSION = '5.45.3';
export const VERSION = '5.45.4';
export const PUBLIC_VERSION = '5';

@ -1418,6 +1418,31 @@ describe('signals', () => {
};
});
test('derived when connected should add new dependency to its reaction even when read outside effect', () => {
let count_a = state(0);
let count_b = state(0);
let which = state(true);
let double = derived(() => ($.get(which) ? $.get(count_a) * 2 : $.get(count_b) * 2));
render_effect(() => {
$.get(double);
});
return () => {
flushSync();
assert.equal($.get(double!), 0);
set(which, false);
$.get(double); // read before render effect has a chance to rerun
flushSync();
assert.equal($.get(double!), 0);
set(count_b, 1);
flushSync();
assert.equal($.get(double!), 2);
};
});
test('$effect.root inside deriveds stay alive independently', () => {
const log: any[] = [];
const c = state(0);

Loading…
Cancel
Save