From: Evan You Date: Mon, 15 Apr 2024 16:05:37 +0000 (+0800) Subject: chore: Merge branch 'main' into minor X-Git-Tag: v3.5.0-alpha.1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb5c31e61480bae971df6817d4a65a511bd8fa90;p=thirdparty%2Fvuejs%2Fcore.git chore: Merge branch 'main' into minor --- bb5c31e61480bae971df6817d4a65a511bd8fa90 diff --cc packages/reactivity/src/baseHandlers.ts index c8034dd072,943f329571..9a899c9558 --- a/packages/reactivity/src/baseHandlers.ts +++ b/packages/reactivity/src/baseHandlers.ts @@@ -38,10 -43,49 +38,12 @@@ const builtInSymbols = new Set .filter(isSymbol), ) - function hasOwnProperty(this: object, key: string) { -const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations() - -function createArrayInstrumentations() { - const instrumentations: Record = {} - // instrument identity-sensitive Array methods to account for possible reactive - // values - ;(['includes', 'indexOf', 'lastIndexOf'] as const).forEach(key => { - instrumentations[key] = function (this: unknown[], ...args: unknown[]) { - const arr = toRaw(this) as any - for (let i = 0, l = this.length; i < l; i++) { - track(arr, TrackOpTypes.GET, i + '') - } - // we run the method using the original args first (which may be reactive) - const res = arr[key](...args) - if (res === -1 || res === false) { - // if that didn't work, run it again using raw values. - return arr[key](...args.map(toRaw)) - } else { - return res - } - } - }) - // instrument length-altering mutation methods to avoid length being tracked - // which leads to infinite loops in some cases (#2137) - ;(['push', 'pop', 'shift', 'unshift', 'splice'] as const).forEach(key => { - instrumentations[key] = function (this: unknown[], ...args: unknown[]) { - pauseTracking() - pauseScheduling() - const res = (toRaw(this) as any)[key].apply(this, args) - resetScheduling() - resetTracking() - return res - } - }) - return instrumentations -} - + function hasOwnProperty(this: object, key: unknown) { + // #10455 hasOwnProperty may be called with non-string values + if (!isSymbol(key)) key = String(key) const obj = toRaw(this) track(obj, TrackOpTypes.HAS, key) - return obj.hasOwnProperty(key) + return obj.hasOwnProperty(key as string) } class BaseReactiveHandler implements ProxyHandler {