fix(reactivity): fix currentScope loss when running detached effect scope (#5575)
This commit is contained in:
@@ -6,7 +6,8 @@ import {
|
||||
onScopeDispose,
|
||||
computed,
|
||||
ref,
|
||||
ComputedRef
|
||||
ComputedRef,
|
||||
getCurrentScope
|
||||
} from '../src'
|
||||
|
||||
describe('reactivity/effect/scope', () => {
|
||||
@@ -263,4 +264,17 @@ describe('reactivity/effect/scope', () => {
|
||||
expect(watchSpy).toHaveBeenCalledTimes(1)
|
||||
expect(watchEffectSpy).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('getCurrentScope() stays valid when running a detached nested EffectScope', () => {
|
||||
const parentScope = new EffectScope()
|
||||
|
||||
parentScope.run(() => {
|
||||
const currentScope = getCurrentScope()
|
||||
expect(currentScope).toBeDefined()
|
||||
const detachedScope = new EffectScope(true)
|
||||
detachedScope.run(() => {})
|
||||
|
||||
expect(getCurrentScope()).toBe(currentScope)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user