refactor(reactivity): remove stale API markReadonly

BREAKING CHANGE: `markReadonly` has been removed.
This commit is contained in:
Evan You 2020-04-13 17:39:48 -04:00
parent 9e9d264412
commit e8a866ec99
4 changed files with 0 additions and 24 deletions

View File

@ -5,7 +5,6 @@ import {
isReactive, isReactive,
isReadonly, isReadonly,
markNonReactive, markNonReactive,
markReadonly,
lock, lock,
unlock, unlock,
effect, effect,
@ -424,17 +423,6 @@ describe('reactivity/readonly', () => {
expect(isReactive(obj.bar)).toBe(false) 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', () => { test('should make ref readonly', () => {
const n: any = readonly(ref(1)) const n: any = readonly(ref(1))
n.value = 2 n.value = 2

View File

@ -7,7 +7,6 @@ export {
isReadonly, isReadonly,
shallowReadonly, shallowReadonly,
toRaw, toRaw,
markReadonly,
markNonReactive markNonReactive
} from './reactive' } from './reactive'
export { export {

View File

@ -20,7 +20,6 @@ const readonlyToRaw = new WeakMap<any, any>()
// WeakSets for values that are marked readonly or non-reactive during // WeakSets for values that are marked readonly or non-reactive during
// observable creation. // observable creation.
const readonlyValues = new WeakSet<any>()
const nonReactiveValues = new WeakSet<any>() const nonReactiveValues = new WeakSet<any>()
const collectionTypes = new Set<Function>([Set, Map, WeakMap, WeakSet]) const collectionTypes = new Set<Function>([Set, Map, WeakMap, WeakSet])
@ -47,10 +46,6 @@ export function reactive(target: object) {
if (readonlyToRaw.has(target)) { if (readonlyToRaw.has(target)) {
return target return target
} }
// target is explicitly marked as readonly by user
if (readonlyValues.has(target)) {
return readonly(target)
}
if (isRef(target)) { if (isRef(target)) {
return target return target
} }
@ -156,11 +151,6 @@ export function toRaw<T>(observed: T): T {
return reactiveToRaw.get(observed) || readonlyToRaw.get(observed) || observed return reactiveToRaw.get(observed) || readonlyToRaw.get(observed) || observed
} }
export function markReadonly<T>(value: T): T {
readonlyValues.add(value)
return value
}
export function markNonReactive<T extends object>(value: T): T { export function markNonReactive<T extends object>(value: T): T {
nonReactiveValues.add(value) nonReactiveValues.add(value)
return value return value

View File

@ -13,7 +13,6 @@ export {
isReadonly, isReadonly,
shallowReactive, shallowReactive,
toRaw, toRaw,
markReadonly,
markNonReactive markNonReactive
} from '@vue/reactivity' } from '@vue/reactivity'
export { computed } from './apiComputed' export { computed } from './apiComputed'