Skip to content

Commit

Permalink
fix(reactivity): avoid wrapping extended array methods
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Aug 9, 2024
1 parent 70e7329 commit da91541
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/reactivity/src/arrayInstrumentations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ function iterator(
// higher than that
type ArrayMethods = keyof Array<any> | 'findLast' | 'findLastIndex'

const arrayProto = Array.prototype
// instrument functions that read (potentially) all items
// to take ARRAY_ITERATE dependency
function apply(
Expand All @@ -237,6 +238,12 @@ function apply(
wrappedRetFn?: (result: any) => unknown,
) {
const arr = shallowReadArray(self)
// @ts-expect-error
if (arr[method] !== arrayProto[method]) {
// @ts-expect-error
return arr[method](fn, thisArg)
}

let needsWrap = false
let wrappedFn = fn
if (arr !== self) {
Expand Down

0 comments on commit da91541

Please sign in to comment.