Skip to content

Commit db9c566

Browse files
committed
fix: account for nested render calls
close vuejs#13131
1 parent 895669f commit db9c566

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/core/instance/render.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import VNode, { createEmptyVNode } from '../vdom/vnode'
1515

1616
import { isUpdatingChildComponent } from './lifecycle'
1717
import type { Component } from 'types/component'
18-
import { setCurrentInstance } from 'v3/currentInstance'
18+
import { currentInstance, setCurrentInstance } from 'v3/currentInstance'
1919
import { syncSetupSlots } from 'v3/apiSetup'
2020

2121
export function initRender(vm: Component) {
@@ -120,11 +120,10 @@ export function renderMixin(Vue: typeof Component) {
120120
// to the data on the placeholder node.
121121
vm.$vnode = _parentVnode!
122122
// render self
123+
const prevInst = currentInstance
124+
const prevRenderInst = currentRenderingInstance
123125
let vnode
124126
try {
125-
// There's no need to maintain a stack because all render fns are called
126-
// separately from one another. Nested component's render fns are called
127-
// when parent component is patched.
128127
setCurrentInstance(vm)
129128
currentRenderingInstance = vm
130129
vnode = render.call(vm._renderProxy, vm.$createElement)
@@ -148,8 +147,8 @@ export function renderMixin(Vue: typeof Component) {
148147
vnode = vm._vnode
149148
}
150149
} finally {
151-
currentRenderingInstance = null
152-
setCurrentInstance()
150+
currentRenderingInstance = prevRenderInst
151+
setCurrentInstance(prevInst)
153152
}
154153
// if the returned array contains only a single node, allow it
155154
if (isArray(vnode) && vnode.length === 1) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy