Skip to content

Commit 4ca5de7

Browse files
committed
chore: minor tweaks
1 parent 80764e8 commit 4ca5de7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/reactivity/src/arrayInstrumentations.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,17 @@ function apply(
239239
args?: IArguments,
240240
) {
241241
const arr = shallowReadArray(self)
242-
let methodFn
242+
const needsWrap = arr !== self && !isShallow(self)
243243
// @ts-expect-error our code is limited to es2016 but user code is not
244-
if ((methodFn = arr[method]) !== arrayProto[method]) {
244+
const methodFn = arr[method]
245+
// @ts-expect-error
246+
if (methodFn !== arrayProto[method]) {
245247
const result = methodFn.apply(arr, args)
246-
return arr !== self && !isShallow(self) ? toReactive(result) : result
248+
return needsWrap ? toReactive(result) : result
247249
}
248250

249-
let needsWrap = false
250251
let wrappedFn = fn
251252
if (arr !== self) {
252-
needsWrap = !isShallow(self)
253253
if (needsWrap) {
254254
wrappedFn = function (this: unknown, item, index) {
255255
return fn.call(this, toReactive(item), index, self)

0 commit comments

Comments
 (0)