File tree 3 files changed +30
-7
lines changed
3 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,7 @@ export enum EffectFlags {
45
45
NOTIFIED = 1 << 3 ,
46
46
DIRTY = 1 << 4 ,
47
47
ALLOW_RECURSE = 1 << 5 ,
48
- NO_BATCH = 1 << 6 ,
49
- PAUSED = 1 << 7 ,
48
+ PAUSED = 1 << 6 ,
50
49
}
51
50
52
51
/**
@@ -169,9 +168,6 @@ export class ReactiveEffect<T = any>
169
168
) {
170
169
return
171
170
}
172
- if ( this . flags & EffectFlags . NO_BATCH ) {
173
- return this . trigger ( )
174
- }
175
171
if ( ! ( this . flags & EffectFlags . NOTIFIED ) ) {
176
172
this . flags |= EffectFlags . NOTIFIED
177
173
this . nextEffect = batchedEffect
@@ -267,6 +263,7 @@ export function endBatch(): void {
267
263
return
268
264
}
269
265
266
+ batchDepth --
270
267
let error : unknown
271
268
while ( batchedEffect ) {
272
269
let e : ReactiveEffect | undefined = batchedEffect
@@ -286,7 +283,6 @@ export function endBatch(): void {
286
283
}
287
284
}
288
285
289
- batchDepth --
290
286
if ( error ) throw error
291
287
}
292
288
Original file line number Diff line number Diff line change @@ -1856,4 +1856,32 @@ describe('api: watch', () => {
1856
1856
1857
1857
warn . mockRestore ( )
1858
1858
} )
1859
+
1860
+ it ( 'should be executed correctly' , ( ) => {
1861
+ const v = ref ( 1 )
1862
+ let foo = ''
1863
+
1864
+ watch (
1865
+ v ,
1866
+ ( ) => {
1867
+ foo += '1'
1868
+ } ,
1869
+ {
1870
+ flush : 'sync' ,
1871
+ } ,
1872
+ )
1873
+ watch (
1874
+ v ,
1875
+ ( ) => {
1876
+ foo += '2'
1877
+ } ,
1878
+ {
1879
+ flush : 'sync' ,
1880
+ } ,
1881
+ )
1882
+
1883
+ expect ( foo ) . toBe ( '' )
1884
+ v . value ++
1885
+ expect ( foo ) . toBe ( '12' )
1886
+ } )
1859
1887
} )
Original file line number Diff line number Diff line change @@ -394,7 +394,6 @@ function doWatch(
394
394
395
395
let scheduler : EffectScheduler
396
396
if ( flush === 'sync' ) {
397
- effect . flags |= EffectFlags . NO_BATCH
398
397
scheduler = job as any // the scheduler function gets called directly
399
398
} else if ( flush === 'post' ) {
400
399
scheduler = ( ) => queuePostRenderEffect ( job , instance && instance . suspense )
You can’t perform that action at this time.
0 commit comments