Skip to content

Commit 40cb14a

Browse files
authored
fix(mockReactivityDeep): add parameter seen for mockReactivityDeep. (#759)
1 parent d7d9b54 commit 40cb14a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/reactivity/reactive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function mockReactivityDeep(obj: any, seen = new Set()) {
150150
) {
151151
continue
152152
}
153-
mockReactivityDeep(value)
153+
mockReactivityDeep(value, seen)
154154
}
155155
}
156156

test/ssr/ssrReactive.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ import {
1111
isRef,
1212
set,
1313
shallowRef,
14+
getCurrentInstance,
15+
nextTick,
1416
} from '../../src'
1517
import { createRenderer } from 'vue-server-renderer'
18+
import { mockWarn } from '../helpers'
1619

1720
describe('SSR Reactive', () => {
21+
mockWarn(true)
1822
beforeEach(() => {
1923
process.env.VUE_ENV = 'server'
2024
})
@@ -118,4 +122,27 @@ describe('SSR Reactive', () => {
118122
set(state.value, 'new', ref(true))
119123
expect(JSON.stringify(state.value)).toBe('{"old":false,"new":true}')
120124
})
125+
126+
// test the input parameter of mockReactivityDeep
127+
it('ssr should not RangeError: Maximum call stack size exceeded', async () => {
128+
new Vue({
129+
setup() {
130+
// @ts-expect-error
131+
const app = getCurrentInstance().proxy
132+
let mockNt: any = []
133+
mockNt.__ob__ = {}
134+
const test = reactive({
135+
app,
136+
mockNt,
137+
})
138+
return {
139+
test,
140+
}
141+
},
142+
})
143+
await nextTick()
144+
expect(
145+
`"RangeError: Maximum call stack size exceeded"`
146+
).not.toHaveBeenWarned()
147+
})
121148
})

0 commit comments

Comments
 (0)