File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
23
23
ref ,
24
24
shallowRef ,
25
25
toRaw ,
26
+ triggerRef ,
26
27
} from '../src'
27
28
import { EffectFlags , pauseTracking , resetTracking } from '../src/effect'
28
29
import type { ComputedRef , ComputedRefImpl } from '../src/computed'
@@ -1004,4 +1005,10 @@ describe('reactivity/computed', () => {
1004
1005
await nextTick ( )
1005
1006
expect ( serializeInner ( root ) ) . toBe ( `<button>Step</button><p>Step 2</p>` )
1006
1007
} )
1008
+
1009
+ it ( 'manual trigger computed' , ( ) => {
1010
+ const cValue = computed ( ( ) => 1 )
1011
+ triggerRef ( cValue )
1012
+ expect ( cValue . value ) . toBe ( 1 )
1013
+ } )
1007
1014
} )
Original file line number Diff line number Diff line change @@ -352,7 +352,12 @@ export function refreshComputed(computed: ComputedRefImpl): undefined {
352
352
// and therefore tracks no deps, thus we cannot rely on the dirty check.
353
353
// Instead, computed always re-evaluate and relies on the globalVersion
354
354
// fast path above for caching.
355
- if ( dep . version > 0 && ! computed . isSSR && ! isDirty ( computed ) ) {
355
+ if (
356
+ dep . version > 0 &&
357
+ ! computed . isSSR &&
358
+ computed . deps &&
359
+ ! isDirty ( computed )
360
+ ) {
356
361
computed . flags &= ~ EffectFlags . RUNNING
357
362
return
358
363
}
You can’t perform that action at this time.
0 commit comments