.filter(isSymbol),
)
- function hasOwnProperty(this: object, key: string) {
-const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations()
-
-function createArrayInstrumentations() {
- const instrumentations: Record<string, Function> = {}
- // 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<Target> {