File tree Expand file tree Collapse file tree 4 files changed +19
-8
lines changed
tests/runtime-runes/samples/derived-map Expand file tree Collapse file tree 4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: more exhaustive check during ` SvelteMap.set ` in deriveds
Original file line number Diff line number Diff line change 1
1
/** @import { Source } from '#client' */
2
2
import { DEV } from 'esm-env' ;
3
- import { source , set } from '../internal/client/reactivity/sources.js' ;
3
+ import { set , source } from '../internal/client/reactivity/sources.js' ;
4
4
import { get } from '../internal/client/runtime.js' ;
5
5
import { increment } from './utils.js' ;
6
6
@@ -102,12 +102,15 @@ export class SvelteMap extends Map {
102
102
increment ( version ) ;
103
103
} else if ( prev_res !== value ) {
104
104
increment ( s ) ;
105
- // If no one listening to this property and is listening to the version, or
106
- // the inverse, then we should increment the version to be safe
107
- if (
108
- ( s . reactions === null && version . reactions !== null ) ||
109
- ( s . reactions !== null && version . reactions === null )
110
- ) {
105
+
106
+ // if not every reaction of s is a reaction of version we need to also include version
107
+ var v_reactions = version . reactions === null ? null : new Set ( version . reactions ) ;
108
+ var needs_version_increase =
109
+ v_reactions === null ||
110
+ ! s . reactions ?. every ( ( r ) =>
111
+ /** @type {NonNullable<typeof v_reactions> } */ ( v_reactions ) . has ( r )
112
+ ) ;
113
+ if ( needs_version_increase ) {
111
114
increment ( version ) ;
112
115
}
113
116
}
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { test } from '../../test';
3
3
4
4
export default test ( {
5
5
html : `Loading` ,
6
-
7
6
async test ( { assert, target } ) {
8
7
await Promise . resolve ( ) ;
9
8
flushSync ( ) ;
Original file line number Diff line number Diff line change 24
24
}
25
25
26
26
const value = $derived (get_async (1 ));
27
+ const value2 = $derived (get_async (1 ));
28
+ // both values are read before the set
29
+ value;
30
+ value2;
27
31
</script >
28
32
29
33
{#if value instanceof Promise }
You can’t perform that action at this time.
0 commit comments