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(ssr): fix array setting error at created in ssr [#12632] #12633

Merged
merged 2 commits into from Jul 8, 2022
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
4 changes: 4 additions & 0 deletions packages/server-renderer/test/ssr-reactivity.spec.ts
Expand Up @@ -93,6 +93,10 @@ describe('SSR Reactive', () => {

set(state.value, 1, {})
expect(isReactive(state.value[1])).toBe(true)

const rawArr = []
set(rawArr, 1, {})
expect(isReactive(rawArr[1])).toBe(false)
})

// #550
Expand Down
2 changes: 1 addition & 1 deletion src/core/observer/index.ts
Expand Up @@ -241,7 +241,7 @@ export function set(
target.length = Math.max(target.length, key)
target.splice(key, 1, val)
// when mocking for SSR, array methods are not hijacked
if (!ob.shallow && ob.mock) {
if (ob && !ob.shallow && ob.mock) {
observe(val, false, true)
}
return val
Expand Down