fix(reactivity): Map/Set identity methods should work even if raw value contains reactive entries

fix #799
This commit is contained in:
Evan You
2020-03-06 11:10:02 -05:00
parent 16f9e63951
commit cc69fd72e3
5 changed files with 63 additions and 13 deletions

View File

@@ -23,7 +23,14 @@ const arrayInstrumentations: Record<string, Function> = {}
for (let i = 0, l = (this as any).length; i < l; i++) {
track(arr, TrackOpTypes.GET, i + '')
}
return arr[key](...args.map(toRaw))
// we run the method using the orignal args first (which may be reactive)
const res = arr[key](...args)
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return arr[key](...args.map(toRaw))
} else {
return res
}
}
})