File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: ensure unowned deriveds correctly update
Original file line number Diff line number Diff line change @@ -162,9 +162,9 @@ export function check_dirtiness(reaction) {
162
162
163
163
if ( ( flags & MAYBE_DIRTY ) !== 0 ) {
164
164
var dependencies = reaction . deps ;
165
+ var is_unowned = ( flags & UNOWNED ) !== 0 ;
165
166
166
167
if ( dependencies !== null ) {
167
- var is_unowned = ( flags & UNOWNED ) !== 0 ;
168
168
var i ;
169
169
170
170
if ( ( flags & DISCONNECTED ) !== 0 ) {
@@ -198,7 +198,10 @@ export function check_dirtiness(reaction) {
198
198
}
199
199
}
200
200
201
- set_signal_status ( reaction , CLEAN ) ;
201
+ // Unowned signals should never be marked as clean.
202
+ if ( ! is_unowned ) {
203
+ set_signal_status ( reaction , CLEAN ) ;
204
+ }
202
205
}
203
206
204
207
return false ;
Original file line number Diff line number Diff line change @@ -676,4 +676,21 @@ describe('signals', () => {
676
676
assert . equal ( d . deps ?. length , 1 ) ;
677
677
} ;
678
678
} ) ;
679
+
680
+ test ( 'unowned deriveds correctly update' , ( ) => {
681
+ return ( ) => {
682
+ const arr1 = proxy < { a : number } [ ] > ( [ ] ) ;
683
+ const arr2 = proxy ( [ ] ) ;
684
+ const combined = derived ( ( ) => [ ...arr1 , ...arr2 ] ) ;
685
+ const derived_length = derived ( ( ) => $ . get ( combined ) . length ) ;
686
+
687
+ assert . deepEqual ( $ . get ( combined ) , [ ] ) ;
688
+ assert . equal ( $ . get ( derived_length ) , 0 ) ;
689
+
690
+ arr1 . push ( { a : 1 } ) ;
691
+
692
+ assert . deepEqual ( $ . get ( combined ) , [ { a : 1 } ] ) ;
693
+ assert . equal ( $ . get ( derived_length ) , 1 ) ;
694
+ } ;
695
+ } ) ;
679
696
} ) ;
You can’t perform that action at this time.
0 commit comments