Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(mockReactivityDeep): add parameter seen for mockReactivityDeep. (#…
  • Loading branch information
ygj6 committed Jul 14, 2021
1 parent d7d9b54 commit 40cb14a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/reactivity/reactive.ts
Expand Up @@ -150,7 +150,7 @@ function mockReactivityDeep(obj: any, seen = new Set()) {
) {
continue
}
mockReactivityDeep(value)
mockReactivityDeep(value, seen)
}
}

Expand Down
27 changes: 27 additions & 0 deletions test/ssr/ssrReactive.spec.ts
Expand Up @@ -11,10 +11,14 @@ import {
isRef,
set,
shallowRef,
getCurrentInstance,
nextTick,
} from '../../src'
import { createRenderer } from 'vue-server-renderer'
import { mockWarn } from '../helpers'

describe('SSR Reactive', () => {
mockWarn(true)
beforeEach(() => {
process.env.VUE_ENV = 'server'
})
Expand Down Expand Up @@ -118,4 +122,27 @@ describe('SSR Reactive', () => {
set(state.value, 'new', ref(true))
expect(JSON.stringify(state.value)).toBe('{"old":false,"new":true}')
})

// test the input parameter of mockReactivityDeep
it('ssr should not RangeError: Maximum call stack size exceeded', async () => {
new Vue({
setup() {
// @ts-expect-error
const app = getCurrentInstance().proxy
let mockNt: any = []
mockNt.__ob__ = {}
const test = reactive({
app,
mockNt,
})
return {
test,
}
},
})
await nextTick()
expect(
`"RangeError: Maximum call stack size exceeded"`
).not.toHaveBeenWarned()
})
})

0 comments on commit 40cb14a

Please sign in to comment.