Skip to content

Commit d52907f

Browse files
committed
fix(runtime-core): ensure consistent identity of $forceUpdate and $nextTick instance methods
fix #5556
1 parent 8ccbb09 commit d52907f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/runtime-core/src/component.ts

+9
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,15 @@ export interface ComponentInternalInstance {
440440
* @internal
441441
*/
442442
[LifecycleHooks.SERVER_PREFETCH]: LifecycleHook<() => Promise<unknown>>
443+
444+
/**
445+
* For caching bound $forceUpdate on public proxy access
446+
*/
447+
f?: () => void
448+
/**
449+
* For caching bound $nextTick on public proxy access
450+
*/
451+
n?: () => Promise<void>
443452
}
444453

445454
const emptyAppContext = createAppContext()

packages/runtime-core/src/componentPublicInstance.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ export const publicPropertiesMap: PublicPropertiesMap =
252252
$root: i => getPublicInstance(i.root),
253253
$emit: i => i.emit,
254254
$options: i => (__FEATURE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type),
255-
$forceUpdate: i => () => queueJob(i.update),
256-
$nextTick: i => nextTick.bind(i.proxy!),
255+
$forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
256+
$nextTick: i => i.n || (i.n = nextTick.bind(i.proxy!)),
257257
$watch: i => (__FEATURE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP)
258258
} as PublicPropertiesMap)
259259

0 commit comments

Comments
 (0)