Skip to content

Commit

Permalink
fix(ssr/reactivity): fix array setting error at created in ssr [#12632]…
Browse files Browse the repository at this point in the history
… (#12633)

fix #12632
  • Loading branch information
freedomlang authored Jul 8, 2022
1 parent 15e6f1d commit ca7daef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/server-renderer/test/ssr-reactivity.spec.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit ca7daef

Please sign in to comment.