| 338 | |
| 339 | // instrument identity-sensitive methods to account for reactive proxies |
| 340 | function searchProxy( |
| 341 | self: unknown[], |
| 342 | method: keyof Array<any>, |
| 343 | args: unknown[], |
| 344 | ) { |
| 345 | const arr = toRaw(self) as any |
| 346 | track(arr, TrackOpTypes.ITERATE, ARRAY_ITERATE_KEY) |
| 347 | // we run the method using the original args first (which may be reactive) |
| 348 | const res = arr[method](...args) |
| 349 | |
| 350 | // if that didn't work, run it again using raw values. |
| 351 | if ((res === -1 || res === false) && isProxy(args[0])) { |
| 352 | args[0] = toRaw(args[0]) |
| 353 | return arr[method](...args) |
| 354 | } |
| 355 | |
| 356 | return res |
| 357 | } |
| 358 | |
| 359 | // instrument length-altering mutation methods to avoid length being tracked |
| 360 | // which leads to infinite loops in some cases (#2137) |