File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -277,4 +277,16 @@ describe('watch', () => {
277
277
278
278
expect ( dummy ) . toEqual ( [ 1 , 2 , 3 ] )
279
279
} )
280
+
281
+ test ( 'watch with immediate reset and sync flush' , ( ) => {
282
+ const value = ref ( false )
283
+
284
+ watch ( value , ( ) => {
285
+ value . value = false
286
+ } )
287
+
288
+ value . value = true
289
+ value . value = true
290
+ expect ( value . value ) . toBe ( false )
291
+ } )
280
292
} )
Original file line number Diff line number Diff line change @@ -264,11 +264,11 @@ export function watch(
264
264
: oldValue ,
265
265
boundCleanup ,
266
266
]
267
+ oldValue = newValue
267
268
call
268
269
? call ( cb ! , WatchErrorCodes . WATCH_CALLBACK , args )
269
270
: // @ts -expect-error
270
271
cb ! ( ...args )
271
- oldValue = newValue
272
272
} finally {
273
273
activeWatcher = currentWatcher
274
274
}
You can’t perform that action at this time.
0 commit comments