]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: Merge branch 'main' into minor
authorEvan You <yyx990803@gmail.com>
Mon, 15 Apr 2024 16:05:37 +0000 (00:05 +0800)
committerEvan You <yyx990803@gmail.com>
Mon, 15 Apr 2024 16:05:37 +0000 (00:05 +0800)
1  2 
packages/reactivity/__tests__/effectScope.spec.ts
packages/reactivity/__tests__/reactiveArray.spec.ts
packages/reactivity/src/baseHandlers.ts
packages/reactivity/src/collectionHandlers.ts
packages/runtime-core/src/component.ts
packages/runtime-core/src/componentPublicInstance.ts

index c8034dd072d8ab997dc3dbf7ab359d168ee5512f,943f329571c1c21a52f79a1ec4c4fe4f261b6f09..9a899c9558b5cd886abaedb71469ec4c8a32479b
@@@ -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<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> {