fix(runtime-core): ensure consistent identity of $forceUpdate and $nextTick instance methods

fix #5556
This commit is contained in:
Evan You 2022-05-10 14:17:04 +08:00
parent 8ccbb0912a
commit d52907f4eb
2 changed files with 11 additions and 2 deletions

View 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()

View 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)