Skip to content

Commit

Permalink
fix: account for nested render calls
Browse files Browse the repository at this point in the history
close #13131
  • Loading branch information
yyx990803 committed Dec 14, 2023
1 parent 895669f commit db9c566
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/core/instance/render.ts
Expand Up @@ -15,7 +15,7 @@ import VNode, { createEmptyVNode } from '../vdom/vnode'

import { isUpdatingChildComponent } from './lifecycle'
import type { Component } from 'types/component'
import { setCurrentInstance } from 'v3/currentInstance'
import { currentInstance, setCurrentInstance } from 'v3/currentInstance'
import { syncSetupSlots } from 'v3/apiSetup'

export function initRender(vm: Component) {
Expand Down Expand Up @@ -120,11 +120,10 @@ export function renderMixin(Vue: typeof Component) {
// to the data on the placeholder node.
vm.$vnode = _parentVnode!
// render self
const prevInst = currentInstance
const prevRenderInst = currentRenderingInstance
let vnode
try {
// There's no need to maintain a stack because all render fns are called
// separately from one another. Nested component's render fns are called
// when parent component is patched.
setCurrentInstance(vm)
currentRenderingInstance = vm
vnode = render.call(vm._renderProxy, vm.$createElement)
Expand All @@ -148,8 +147,8 @@ export function renderMixin(Vue: typeof Component) {
vnode = vm._vnode
}
} finally {
currentRenderingInstance = null
setCurrentInstance()
currentRenderingInstance = prevRenderInst
setCurrentInstance(prevInst)
}
// if the returned array contains only a single node, allow it
if (isArray(vnode) && vnode.length === 1) {
Expand Down

0 comments on commit db9c566

Please sign in to comment.