revert: fix(reactivity): correct dirty assign in render function (#10091)
This reverts commit 8d04205041
.
close #10098
close #10100
This commit is contained in:
parent
fd337dddd1
commit
8b1848173b
|
@ -3,19 +3,16 @@ import {
|
||||||
type ReactiveEffectRunner,
|
type ReactiveEffectRunner,
|
||||||
TrackOpTypes,
|
TrackOpTypes,
|
||||||
TriggerOpTypes,
|
TriggerOpTypes,
|
||||||
computed,
|
|
||||||
effect,
|
effect,
|
||||||
markRaw,
|
markRaw,
|
||||||
reactive,
|
reactive,
|
||||||
readonly,
|
readonly,
|
||||||
ref,
|
|
||||||
shallowReactive,
|
shallowReactive,
|
||||||
stop,
|
stop,
|
||||||
toRaw,
|
toRaw,
|
||||||
} from '../src/index'
|
} from '../src/index'
|
||||||
import { pauseScheduling, resetScheduling } from '../src/effect'
|
import { pauseScheduling, resetScheduling } from '../src/effect'
|
||||||
import { ITERATE_KEY, getDepFromReactive } from '../src/reactiveEffect'
|
import { ITERATE_KEY, getDepFromReactive } from '../src/reactiveEffect'
|
||||||
import { h, nextTick, nodeOps, render, serialize } from '@vue/runtime-test'
|
|
||||||
|
|
||||||
describe('reactivity/effect', () => {
|
describe('reactivity/effect', () => {
|
||||||
it('should run the passed function once (wrapped by a effect)', () => {
|
it('should run the passed function once (wrapped by a effect)', () => {
|
||||||
|
@ -1014,35 +1011,6 @@ describe('reactivity/effect', () => {
|
||||||
expect(counterSpy).toHaveBeenCalledTimes(1)
|
expect(counterSpy).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
// #10082
|
|
||||||
it('should set dirtyLevel when effect is allowRecurse and is running', async () => {
|
|
||||||
const s = ref(0)
|
|
||||||
const n = computed(() => s.value + 1)
|
|
||||||
|
|
||||||
const Child = {
|
|
||||||
setup() {
|
|
||||||
s.value++
|
|
||||||
return () => n.value
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderSpy = vi.fn()
|
|
||||||
const Parent = {
|
|
||||||
setup() {
|
|
||||||
return () => {
|
|
||||||
renderSpy()
|
|
||||||
return [n.value, h(Child)]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const root = nodeOps.createElement('div')
|
|
||||||
render(h(Parent), root)
|
|
||||||
await nextTick()
|
|
||||||
expect(serialize(root)).toBe('<div>22</div>')
|
|
||||||
expect(renderSpy).toHaveBeenCalledTimes(2)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('empty dep cleanup', () => {
|
describe('empty dep cleanup', () => {
|
||||||
it('should remove the dep when the effect is stopped', () => {
|
it('should remove the dep when the effect is stopped', () => {
|
||||||
const obj = reactive({ prop: 1 })
|
const obj = reactive({ prop: 1 })
|
||||||
|
|
|
@ -295,9 +295,7 @@ export function triggerEffects(
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
effect._dirtyLevel < dirtyLevel &&
|
effect._dirtyLevel < dirtyLevel &&
|
||||||
(!effect._runnings ||
|
(!effect._runnings || dirtyLevel !== DirtyLevels.ComputedValueDirty)
|
||||||
effect.allowRecurse ||
|
|
||||||
dirtyLevel !== DirtyLevels.ComputedValueDirty)
|
|
||||||
) {
|
) {
|
||||||
const lastDirtyLevel = effect._dirtyLevel
|
const lastDirtyLevel = effect._dirtyLevel
|
||||||
effect._dirtyLevel = dirtyLevel
|
effect._dirtyLevel = dirtyLevel
|
||||||
|
|
Loading…
Reference in New Issue