fix(reactivity): use correct thisArg for collection method callbacks (#1132)

This commit is contained in:
龙腾道
2020-05-07 01:41:34 +08:00
committed by GitHub
parent 4df180607d
commit e08f6f0ede
2 changed files with 16 additions and 2 deletions

View File

@@ -146,9 +146,9 @@ function createForEach(isReadonly: boolean) {
// 1. invoked with the reactive map as `this` and 3rd arg
// 2. the value received should be a corresponding reactive/readonly.
function wrappedCallback(value: unknown, key: unknown) {
return callback.call(observed, wrap(value), wrap(key), observed)
return callback.call(thisArg, wrap(value), wrap(key), observed)
}
return getProto(target).forEach.call(target, wrappedCallback, thisArg)
return getProto(target).forEach.call(target, wrappedCallback)
}
}