From da91541796698a6d049df8d4ffc2685ff8c0f78a Mon Sep 17 00:00:00 2001 From: daiwei Date: Wed, 19 Jul 2023 14:17:40 +0800 Subject: [PATCH] fix(reactivity): avoid wrapping extended array methods close #11570 --- packages/reactivity/src/arrayInstrumentations.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/reactivity/src/arrayInstrumentations.ts b/packages/reactivity/src/arrayInstrumentations.ts index 69f08d6c5d1..fa40f1687b3 100644 --- a/packages/reactivity/src/arrayInstrumentations.ts +++ b/packages/reactivity/src/arrayInstrumentations.ts @@ -227,6 +227,7 @@ function iterator( // higher than that type ArrayMethods = keyof Array | 'findLast' | 'findLastIndex' +const arrayProto = Array.prototype // instrument functions that read (potentially) all items // to take ARRAY_ITERATE dependency function apply( @@ -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) {