From e8a866ec9945ec0464035be4c4c58d6212080a50 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 13 Apr 2020 17:39:48 -0400 Subject: [PATCH] refactor(reactivity): remove stale API `markReadonly` BREAKING CHANGE: `markReadonly` has been removed. --- packages/reactivity/__tests__/readonly.spec.ts | 12 ------------ packages/reactivity/src/index.ts | 1 - packages/reactivity/src/reactive.ts | 10 ---------- packages/runtime-core/src/index.ts | 1 - 4 files changed, 24 deletions(-) diff --git a/packages/reactivity/__tests__/readonly.spec.ts b/packages/reactivity/__tests__/readonly.spec.ts index e009022d08c..0138b7ebd5b 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 21a9eae8f8c..91b1829e0de 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 bc1b72524a8..d6f9c67ad39 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 7e4ad2f70a1..334b7c6f3b5 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'