Skip to content

Commit

Permalink
refactor(reactivity): remove stale API markReadonly
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `markReadonly` has been removed.
  • Loading branch information
yyx990803 committed Apr 13, 2020
1 parent 9e9d264 commit e8a866e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 24 deletions.
12 changes: 0 additions & 12 deletions packages/reactivity/__tests__/readonly.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
isReactive,
isReadonly,
markNonReactive,
markReadonly,
lock,
unlock,
effect,
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion packages/reactivity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export {
isReadonly,
shallowReadonly,
toRaw,
markReadonly,
markNonReactive
} from './reactive'
export {
Expand Down
10 changes: 0 additions & 10 deletions packages/reactivity/src/reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export {
isReadonly,
shallowReactive,
toRaw,
markReadonly,
markNonReactive
} from '@vue/reactivity'
export { computed } from './apiComputed'
Expand Down

0 comments on commit e8a866e

Please sign in to comment.