Skip to content

Commit

Permalink
fix(runtime-core): ensure consistent identity of $forceUpdate and $ne…
Browse files Browse the repository at this point in the history
…xtTick instance methods

fix vuejs#5556
  • Loading branch information
yyx990803 authored and iwusong committed May 13, 2022
1 parent 12c4210 commit c399df9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/componentPublicInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c399df9

Please sign in to comment.