'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)
+ })
})
readonlyMap,
reactiveMap,
shallowReactiveMap,
- shallowReadonlyMap
+ shallowReadonlyMap,
+ isReadonly
} from './reactive'
import { TrackOpTypes, TriggerOpTypes } from './operations'
import {
receiver: object
): boolean {
let oldValue = (target as any)[key]
- if (!shallow) {
+ if (!shallow && !isReadonly(value)) {
value = toRaw(value)
oldValue = toRaw(oldValue)
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {