refactor(reactivity): remove stale API markReadonly
BREAKING CHANGE: `markReadonly` has been removed.
This commit is contained in:
parent
9e9d264412
commit
e8a866ec99
@ -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
|
||||
|
@ -7,7 +7,6 @@ export {
|
||||
isReadonly,
|
||||
shallowReadonly,
|
||||
toRaw,
|
||||
markReadonly,
|
||||
markNonReactive
|
||||
} from './reactive'
|
||||
export {
|
||||
|
@ -20,7 +20,6 @@ const readonlyToRaw = new WeakMap<any, any>()
|
||||
|
||||
// WeakSets for values that are marked readonly or non-reactive during
|
||||
// observable creation.
|
||||
const readonlyValues = new WeakSet<any>()
|
||||
const nonReactiveValues = new WeakSet<any>()
|
||||
|
||||
const collectionTypes = new Set<Function>([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<T>(observed: T): T {
|
||||
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 {
|
||||
nonReactiveValues.add(value)
|
||||
return value
|
||||
|
@ -13,7 +13,6 @@ export {
|
||||
isReadonly,
|
||||
shallowReactive,
|
||||
toRaw,
|
||||
markReadonly,
|
||||
markNonReactive
|
||||
} from '@vue/reactivity'
|
||||
export { computed } from './apiComputed'
|
||||
|
Loading…
Reference in New Issue
Block a user