-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(reactivity): lose activeEffectScope when effectScope(true) #5575
fix(reactivity): lose activeEffectScope when effectScope(true) #5575
Conversation
✅ Deploy Preview for vuejs-coverage ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for vue-next-template-explorer ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for vue-sfc-playground ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
ab934c0
to
c7bb868
Compare
Does any maintainer want to review this PR? |
as you may have noticed, we have quite a backlog of PRs, so we are thankful for your patience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a regression test for this?
c7bb868
to
f3314fe
Compare
Sure. |
f3314fe
to
002402e
Compare
|
Maybe it would be better to just change these two positions. constructor(detached = false) {
// 👇🏻 this line
this.parent = activeEffectScope
if (!detached && activeEffectScope) {
this.index =
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
this
) - 1
}
} // nested scope, dereference from parent to avoid memory leaks
// 👇🏻 this line
if (this.index !== undefined && this.parent && !fromParent) {
// optimized O(1) removal
const last = this.parent.scopes!.pop()
if (last && last !== this) {
this.parent.scopes![this.index] = last
last.index = this.index
}
} |
@qq15725 do you have a failing test case so we can add it? |
test case: it('getCurrentScope() stays valid when offed a detached nested EffectScope', () => {
const parentScope = new EffectScope()
parentScope.run(() => {
const currentScope = getCurrentScope()
expect(currentScope).toBeDefined()
const detachedScope = new EffectScope(true)
detachedScope.off()
expect(getCurrentScope()).toBe(currentScope)
})
}) |
Thanks. You don't call |
Vue SFC Playground:
v3.2.30 will be lost activeEffectScope and previous version was worked properly.