]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(reactivity): remove stale API `markReadonly`
authorEvan You <yyx990803@gmail.com>
Mon, 13 Apr 2020 21:39:48 +0000 (17:39 -0400)
committerEvan You <yyx990803@gmail.com>
Mon, 13 Apr 2020 21:39:48 +0000 (17:39 -0400)
BREAKING CHANGE: `markReadonly` has been removed.

packages/reactivity/__tests__/readonly.spec.ts
packages/reactivity/src/index.ts
packages/reactivity/src/reactive.ts
packages/runtime-core/src/index.ts

index e009022d08c6b0f69c606d4b1df0213594219642..0138b7ebd5b63f5b1139a81cc316b02dc0c3200f 100644 (file)
@@ -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
index 21a9eae8f8ccec142ab6079a50b091be25c2832c..91b1829e0dee3ca5dfaf4fefdb543ccab03820c6 100644 (file)
@@ -7,7 +7,6 @@ export {
   isReadonly,
   shallowReadonly,
   toRaw,
-  markReadonly,
   markNonReactive
 } from './reactive'
 export {
index bc1b72524a842919435a1a328d468707e88bb61e..d6f9c67ad3968e7d6be2965949faba02f7ce6bfc 100644 (file)
@@ -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
index 7e4ad2f70a141e938adf747d420cda64f591eeda..334b7c6f3b5aa109cccefbab9d608a94215855da 100644 (file)
@@ -13,7 +13,6 @@ export {
   isReadonly,
   shallowReactive,
   toRaw,
-  markReadonly,
   markNonReactive
 } from '@vue/reactivity'
 export { computed } from './apiComputed'