fix(reactivity): keep previous effect scope
This commit is contained in:
parent
be65b98a33
commit
8dec243dc1
|
@ -62,11 +62,13 @@ export class EffectScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevScope: EffectScope | undefined
|
||||||
/**
|
/**
|
||||||
* This should only be called on non-detached scopes
|
* This should only be called on non-detached scopes
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
on() {
|
on() {
|
||||||
|
this.prevScope = activeEffectScope
|
||||||
activeEffectScope = this
|
activeEffectScope = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ export class EffectScope {
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
off() {
|
off() {
|
||||||
activeEffectScope = this.parent
|
activeEffectScope = this.prevScope
|
||||||
}
|
}
|
||||||
|
|
||||||
stop(fromParent?: boolean) {
|
stop(fromParent?: boolean) {
|
||||||
|
|
|
@ -23,12 +23,16 @@ export default defineComponent({
|
||||||
const container = document.createElement('li')
|
const container = document.createElement('li')
|
||||||
append(container, node)
|
append(container, node)
|
||||||
|
|
||||||
const update = () => {
|
renderEffect(() => {
|
||||||
const [item, index] = block.s
|
const [item, index] = block.s
|
||||||
node.textContent = `${index}. ${item}`
|
node.textContent = `${index}. ${item}`
|
||||||
}
|
})
|
||||||
renderEffect(update)
|
|
||||||
return [container, update]
|
renderEffect(() => {
|
||||||
|
const [item, index] = block.s
|
||||||
|
node.textContent = `${index}/ ${item}`
|
||||||
|
})
|
||||||
|
return container
|
||||||
},
|
},
|
||||||
(item, index) => index,
|
(item, index) => index,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue