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 11/** @import { Source } from '#client' */
22import { DEV } from 'esm-env' ;
3- import { source , set } from '../internal/client/reactivity/sources.js' ;
3+ import { set , source } from '../internal/client/reactivity/sources.js' ;
44import { get } from '../internal/client/runtime.js' ;
55import { increment } from './utils.js' ;
66
@@ -102,12 +102,15 @@ export class SvelteMap extends Map {
102102 increment ( version ) ;
103103 } else if ( prev_res !== value ) {
104104 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 ) {
111114 increment ( version ) ;
112115 }
113116 }
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { test } from '../../test';
33
44export default test ( {
55 html : `Loading` ,
6-
76 async test ( { assert, target } ) {
87 await Promise . resolve ( ) ;
98 flushSync ( ) ;
Original file line number Diff line number Diff line change 2424 }
2525
2626 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;
2731 </script >
2832
2933{#if value instanceof Promise }
You can’t perform that action at this time.
0 commit comments