瀏覽代碼

refactor: remove optional chaining

三咲智子 Kevin Deng 2 年之前
父節點
當前提交
5a0a2bfa9b
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 2 2
      packages/reactivity/src/baseWatch.ts
  2. 3 1
      packages/runtime-core/src/componentOptions.ts

+ 2 - 2
packages/reactivity/src/baseWatch.ts

@@ -215,13 +215,13 @@ export function baseWatch(
       const _cb = cb
       cb = (...args) => {
         _cb(...args)
-        effect?.stop()
+        effect.stop()
       }
     } else {
       const _getter = getter
       getter = () => {
         _getter()
-        effect?.stop()
+        effect.stop()
       }
     }
   }

+ 3 - 1
packages/runtime-core/src/componentOptions.ts

@@ -842,7 +842,9 @@ export function createWatcher(
   const options: WatchOptions = {}
   if (__COMPAT__) {
     const instance =
-      getCurrentScope() === currentInstance?.scope ? currentInstance : null
+      currentInstance && getCurrentScope() === currentInstance.scope
+        ? currentInstance
+        : null
 
     const newValue = getter()
     if (