fix(reactivity): shallowReactive collection to not-readonly (#1212)
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
import { ref, isRef } from '../src/ref'
|
||||
import {
|
||||
reactive,
|
||||
isReactive,
|
||||
toRaw,
|
||||
markRaw,
|
||||
shallowReactive
|
||||
} from '../src/reactive'
|
||||
import { reactive, isReactive, toRaw, markRaw } from '../src/reactive'
|
||||
import { mockWarn } from '@vue/shared'
|
||||
import { computed } from '../src/computed'
|
||||
|
||||
@@ -175,44 +169,4 @@ describe('reactivity/reactive', () => {
|
||||
})
|
||||
expect(isReactive(obj.foo)).toBe(false)
|
||||
})
|
||||
|
||||
describe('shallowReactive', () => {
|
||||
test('should not make non-reactive properties reactive', () => {
|
||||
const props = shallowReactive({ n: { foo: 1 } })
|
||||
expect(isReactive(props.n)).toBe(false)
|
||||
})
|
||||
|
||||
test('should keep reactive properties reactive', () => {
|
||||
const props: any = shallowReactive({ n: reactive({ foo: 1 }) })
|
||||
props.n = reactive({ foo: 2 })
|
||||
expect(isReactive(props.n)).toBe(true)
|
||||
})
|
||||
|
||||
test('should not observe when iterating', () => {
|
||||
const shallowSet = shallowReactive(new Set())
|
||||
const a = {}
|
||||
shallowSet.add(a)
|
||||
|
||||
const spreadA = [...shallowSet][0]
|
||||
expect(isReactive(spreadA)).toBe(false)
|
||||
})
|
||||
|
||||
test('should not get reactive entry', () => {
|
||||
const shallowMap = shallowReactive(new Map())
|
||||
const a = {}
|
||||
const key = 'a'
|
||||
|
||||
shallowMap.set(key, a)
|
||||
|
||||
expect(isReactive(shallowMap.get(key))).toBe(false)
|
||||
})
|
||||
|
||||
test('should not get reactive on foreach', () => {
|
||||
const shallowSet = shallowReactive(new Set())
|
||||
const a = {}
|
||||
shallowSet.add(a)
|
||||
|
||||
shallowSet.forEach(x => expect(isReactive(x)).toBe(false))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user