fix(reactivity): unwrap non-index accessed refs on reactive arrays (#1859)

close #1846
This commit is contained in:
ᴜɴвʏтᴇ
2020-08-22 01:36:41 +08:00
committed by GitHub
parent 191080b0f0
commit 3c05f8bbd6
2 changed files with 22 additions and 4 deletions

View File

@@ -115,6 +115,19 @@ describe('reactivity/ref', () => {
expect((arr[1] as Ref).value).toBe(3)
})
it('should unwrap ref types as props of arrays', () => {
const arr = [ref(0)]
const symbolKey = Symbol('')
arr['' as any] = ref(1)
arr[symbolKey as any] = ref(2)
const arrRef = ref(arr).value
expect(isRef(arrRef[0])).toBe(true)
expect(isRef(arrRef['' as any])).toBe(false)
expect(isRef(arrRef[symbolKey as any])).toBe(false)
expect(arrRef['' as any]).toBe(1)
expect(arrRef[symbolKey as any]).toBe(2)
})
it('should keep tuple types', () => {
const tuple: [number, string, { a: number }, () => number, Ref<number>] = [
0,