fix(reactivity): unwrap non-index accessed refs on reactive arrays (#1859)
close #1846
This commit is contained in:
@@ -63,9 +63,10 @@ function createGetter(isReadonly = false, shallow = false) {
|
||||
|
||||
const res = Reflect.get(target, key, receiver)
|
||||
|
||||
const keyIsSymbol = isSymbol(key)
|
||||
if (
|
||||
isSymbol(key)
|
||||
? builtInSymbols.has(key)
|
||||
keyIsSymbol
|
||||
? builtInSymbols.has(key as symbol)
|
||||
: key === `__proto__` || key === `__v_isRef`
|
||||
) {
|
||||
return res
|
||||
@@ -80,8 +81,12 @@ function createGetter(isReadonly = false, shallow = false) {
|
||||
}
|
||||
|
||||
if (isRef(res)) {
|
||||
// ref unwrapping, only for Objects, not for Arrays.
|
||||
return targetIsArray ? res : res.value
|
||||
// ref unwrapping - does not apply for Array + integer key.
|
||||
const shouldUnwrap =
|
||||
!targetIsArray ||
|
||||
keyIsSymbol ||
|
||||
'' + parseInt(key as string, 10) !== key
|
||||
return shouldUnwrap ? res.value : res
|
||||
}
|
||||
|
||||
if (isObject(res)) {
|
||||
|
||||
Reference in New Issue
Block a user