Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mockReactivityDeep): add parameter seen for mockReactivityDeep. #759

Merged
merged 1 commit into from Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()
})
})