diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index b04d8fefcd0..11a6cafbcf1 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -440,6 +440,15 @@ export interface ComponentInternalInstance { * @internal */ [LifecycleHooks.SERVER_PREFETCH]: LifecycleHook<() => Promise> + + /** + * For caching bound $forceUpdate on public proxy access + */ + f?: () => void + /** + * For caching bound $nextTick on public proxy access + */ + n?: () => Promise } const emptyAppContext = createAppContext() diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index faae5312d30..33e8ce5fac0 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -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)