]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): ensure consistent identity of $forceUpdate and $nextTick instance...
authorEvan You <yyx990803@gmail.com>
Tue, 10 May 2022 06:17:04 +0000 (14:17 +0800)
committerEvan You <yyx990803@gmail.com>
Tue, 10 May 2022 06:17:04 +0000 (14:17 +0800)
fix #5556

packages/runtime-core/src/component.ts
packages/runtime-core/src/componentPublicInstance.ts

index b04d8fefcd0913c7274dafe14ab83ce568e4ada9..11a6cafbcf14784fbfd0671b5aed282866a7e09a 100644 (file)
@@ -440,6 +440,15 @@ export interface ComponentInternalInstance {
    * @internal
    */
   [LifecycleHooks.SERVER_PREFETCH]: LifecycleHook<() => Promise<unknown>>
+
+  /**
+   * For caching bound $forceUpdate on public proxy access
+   */
+  f?: () => void
+  /**
+   * For caching bound $nextTick on public proxy access
+   */
+  n?: () => Promise<void>
 }
 
 const emptyAppContext = createAppContext()
index faae5312d30641a393d2476a0e8b92b34ffb237b..33e8ce5fac0d31220d3274e8e353b5c5b70d553c 100644 (file)
@@ -252,8 +252,8 @@ export const publicPropertiesMap: PublicPropertiesMap =
     $root: i => getPublicInstance(i.root),
     $emit: i => i.emit,
     $options: i => (__FEATURE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type),
-    $forceUpdate: i => () => queueJob(i.update),
-    $nextTick: i => nextTick.bind(i.proxy!),
+    $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
+    $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy!)),
     $watch: i => (__FEATURE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP)
   } as PublicPropertiesMap)