parent
31b99a9139
commit
10293c7a18
@ -574,6 +574,25 @@ describe('api: watch', () => {
|
||||
expect(dummy).toEqual([1, 2, 2, false])
|
||||
})
|
||||
|
||||
it('watching deep ref', async () => {
|
||||
const count = ref(0)
|
||||
const double = computed(() => count.value * 2)
|
||||
const state = reactive([count, double])
|
||||
|
||||
let dummy
|
||||
watch(
|
||||
() => state,
|
||||
state => {
|
||||
dummy = [state[0].value, state[1].value]
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
count.value++
|
||||
await nextTick()
|
||||
expect(dummy).toEqual([1, 2])
|
||||
})
|
||||
|
||||
it('immediate', async () => {
|
||||
const count = ref(0)
|
||||
const cb = jest.fn()
|
||||
|
@ -329,7 +329,9 @@ function traverse(value: unknown, seen: Set<unknown> = new Set()) {
|
||||
return value
|
||||
}
|
||||
seen.add(value)
|
||||
if (isArray(value)) {
|
||||
if (isRef(value)) {
|
||||
traverse(value.value, seen)
|
||||
} else if (isArray(value)) {
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
traverse(value[i], seen)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user