Skip to content

Commit

Permalink
revert: fix(reactivity): correct dirty assign in render function (#10091
Browse files Browse the repository at this point in the history
)

This reverts commit 8d04205.

close #10098
close #10100
  • Loading branch information
yyx990803 committed Jan 13, 2024
1 parent fd337dd commit 8b18481
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
32 changes: 0 additions & 32 deletions packages/reactivity/__tests__/effect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ import {
type ReactiveEffectRunner,
TrackOpTypes,
TriggerOpTypes,
computed,
effect,
markRaw,
reactive,
readonly,
ref,
shallowReactive,
stop,
toRaw,
} from '../src/index'
import { pauseScheduling, resetScheduling } from '../src/effect'
import { ITERATE_KEY, getDepFromReactive } from '../src/reactiveEffect'
import { h, nextTick, nodeOps, render, serialize } from '@vue/runtime-test'

describe('reactivity/effect', () => {
it('should run the passed function once (wrapped by a effect)', () => {
Expand Down Expand Up @@ -1014,35 +1011,6 @@ describe('reactivity/effect', () => {
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', () => {
it('should remove the dep when the effect is stopped', () => {
const obj = reactive({ prop: 1 })
Expand Down
4 changes: 1 addition & 3 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ export function triggerEffects(
}
if (
effect._dirtyLevel < dirtyLevel &&
(!effect._runnings ||
effect.allowRecurse ||
dirtyLevel !== DirtyLevels.ComputedValueDirty)
(!effect._runnings || dirtyLevel !== DirtyLevels.ComputedValueDirty)
) {
const lastDirtyLevel = effect._dirtyLevel
effect._dirtyLevel = dirtyLevel
Expand Down

0 comments on commit 8b18481

Please sign in to comment.