fix(reactivity): retain readonly proxies when setting as reactive property

fix #4986
This commit is contained in:
Evan You
2021-11-25 12:14:20 +08:00
parent 820a143457
commit d145128ab4
2 changed files with 12 additions and 2 deletions

View File

@@ -465,4 +465,13 @@ describe('reactivity/readonly', () => {
'Set operation on key "randomProperty" failed: target is readonly.'
).toHaveBeenWarned()
})
// #4986
test('setting a readonly object as a property of a reactive object should retain readonly proxy', () => {
const r = readonly({})
const rr = reactive({}) as any
rr.foo = r
expect(rr.foo).toBe(r)
expect(isReadonly(rr.foo)).toBe(true)
})
})