fix(ssr/reactivity): fix array setting error at created in ssr [#12632] (#12633)

fix #12632
This commit is contained in:
blackie 2022-07-08 09:44:41 +08:00 committed by GitHub
parent 15e6f1dee4
commit ca7daefaa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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