From: Evan You Date: Tue, 10 May 2022 06:17:04 +0000 (+0800) Subject: fix(runtime-core): ensure consistent identity of $forceUpdate and $nextTick instance... X-Git-Tag: v3.2.34-beta.1~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d52907f4ebc9bcfd7b3141fbebecd4c5b19aa80f;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-core): ensure consistent identity of $forceUpdate and $nextTick instance methods fix #5556 --- diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index b04d8fefcd..11a6cafbcf 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 faae5312d3..33e8ce5fac 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)