File tree Expand file tree Collapse file tree 6 files changed +57
-1
lines changed
src/internal/client/reactivity
tests/runtime-legacy/samples/store-updated-in-reactive-statement Expand file tree Collapse file tree 6 files changed +57
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: ensure reactive graph is fully traversed in the marking phase for non-runes mode
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ import {
33
33
UNOWNED ,
34
34
CLEAN ,
35
35
INSPECT_EFFECT ,
36
- HEAD_EFFECT
36
+ HEAD_EFFECT ,
37
+ MAYBE_DIRTY
37
38
} from '../constants.js' ;
38
39
import { set } from './sources.js' ;
39
40
import * as e from '../errors.js' ;
@@ -281,6 +282,12 @@ export function legacy_pre_effect_reset() {
281
282
for ( var token of context . l . r1 ) {
282
283
var effect = token . effect ;
283
284
285
+ // If the effect is CLEAN, then make it MAYBE_DIRTY. This ensures we traverse through
286
+ // the effects dependencies and correctly ensure each dependency is up-to-date.
287
+ if ( ( effect . f & CLEAN ) !== 0 ) {
288
+ set_signal_status ( effect , MAYBE_DIRTY ) ;
289
+ }
290
+
284
291
if ( check_dirtiness ( effect ) ) {
285
292
update_effect ( effect ) ;
286
293
}
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import { writable } from ' svelte/store' ;
3
+ import { store } from ' ./state.js' ;
4
+
5
+ export let value;
6
+
7
+ const copy = writable (value);
8
+
9
+ $: {
10
+ copy .set (value);
11
+ store .set ({ value });
12
+ }
13
+ </script >
14
+
15
+ <p >{$copy }</p >
Original file line number Diff line number Diff line change
1
+ import { flushSync } from 'svelte' ;
2
+ import { test } from '../../test' ;
3
+ import { store } from './state.js' ;
4
+
5
+ export default test ( {
6
+ html : '<p>0</p><button>1</button>' ,
7
+
8
+ before_test ( ) {
9
+ store . set ( { value : 0 } ) ;
10
+ } ,
11
+
12
+ async test ( { assert, target } ) {
13
+ const button = target . querySelector ( 'button' ) ;
14
+ flushSync ( ( ) => button ?. click ( ) ) ;
15
+
16
+ assert . htmlEqual ( target . innerHTML , '<p>1</p><button>1</button>' ) ;
17
+ }
18
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import { store } from ' ./state.js' ;
3
+ import Child from ' ./Child.svelte' ;
4
+ </script >
5
+
6
+ <Child value ={$store .value } />
7
+
8
+ <button on:click ={() => store .set ({ value: 1 })}>1</button >
Original file line number Diff line number Diff line change
1
+ import { writable } from 'svelte/store' ;
2
+
3
+ export const store = writable ( { value : 0 } ) ;
You can’t perform that action at this time.
0 commit comments