diff --git a/packages/reactivity/__tests__/readonly.spec.ts b/packages/reactivity/__tests__/readonly.spec.ts index e009022d..0138b7eb 100644 --- a/packages/reactivity/__tests__/readonly.spec.ts +++ b/packages/reactivity/__tests__/readonly.spec.ts @@ -5,7 +5,6 @@ import { isReactive, isReadonly, markNonReactive, - markReadonly, lock, unlock, effect, @@ -424,17 +423,6 @@ describe('reactivity/readonly', () => { expect(isReactive(obj.bar)).toBe(false) }) - test('markReadonly', () => { - const obj = reactive({ - foo: { a: 1 }, - bar: markReadonly({ b: 2 }) - }) - expect(isReactive(obj.foo)).toBe(true) - expect(isReactive(obj.bar)).toBe(true) - expect(isReadonly(obj.foo)).toBe(false) - expect(isReadonly(obj.bar)).toBe(true) - }) - test('should make ref readonly', () => { const n: any = readonly(ref(1)) n.value = 2 diff --git a/packages/reactivity/src/index.ts b/packages/reactivity/src/index.ts index 21a9eae8..91b1829e 100644 --- a/packages/reactivity/src/index.ts +++ b/packages/reactivity/src/index.ts @@ -7,7 +7,6 @@ export { isReadonly, shallowReadonly, toRaw, - markReadonly, markNonReactive } from './reactive' export { diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index bc1b7252..d6f9c67a 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -20,7 +20,6 @@ const readonlyToRaw = new WeakMap() // WeakSets for values that are marked readonly or non-reactive during // observable creation. -const readonlyValues = new WeakSet() const nonReactiveValues = new WeakSet() const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]) @@ -47,10 +46,6 @@ export function reactive(target: object) { if (readonlyToRaw.has(target)) { return target } - // target is explicitly marked as readonly by user - if (readonlyValues.has(target)) { - return readonly(target) - } if (isRef(target)) { return target } @@ -156,11 +151,6 @@ export function toRaw(observed: T): T { return reactiveToRaw.get(observed) || readonlyToRaw.get(observed) || observed } -export function markReadonly(value: T): T { - readonlyValues.add(value) - return value -} - export function markNonReactive(value: T): T { nonReactiveValues.add(value) return value diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 7e4ad2f7..334b7c6f 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -13,7 +13,6 @@ export { isReadonly, shallowReactive, toRaw, - markReadonly, markNonReactive } from '@vue/reactivity' export { computed } from './apiComputed'