Skip to content

Commit 7ffb79c

Browse files
authored
fix(runtime-core): correctly track dynamic nodes in renderSlot (#1911)
1 parent 91c4735 commit 7ffb79c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/runtime-core/src/helpers/renderSlot.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { PatchFlags, SlotFlags } from '@vue/shared'
1111
import { warn } from '../warning'
1212

13-
export let isRenderingTemplateSlot = false
13+
export let shouldTrackInSlotRendering = 0
1414

1515
/**
1616
* Compiler runtime helper for rendering `<slot/>`
@@ -39,7 +39,7 @@ export function renderSlot(
3939
// invocation interfering with template-based block tracking, but in
4040
// `renderSlot` we can be sure that it's template-based so we can force
4141
// enable it.
42-
isRenderingTemplateSlot = true
42+
shouldTrackInSlotRendering++
4343
const rendered = (openBlock(),
4444
createBlock(
4545
Fragment,
@@ -49,6 +49,6 @@ export function renderSlot(
4949
? PatchFlags.STABLE_FRAGMENT
5050
: PatchFlags.BAIL
5151
))
52-
isRenderingTemplateSlot = false
52+
shouldTrackInSlotRendering--
5353
return rendered
5454
}

packages/runtime-core/src/vnode.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { currentRenderingInstance } from './componentRenderUtils'
3636
import { RendererNode, RendererElement } from './renderer'
3737
import { NULL_DYNAMIC_COMPONENT } from './helpers/resolveAssets'
3838
import { hmrDirtyComponents } from './hmr'
39-
import { isRenderingTemplateSlot } from './helpers/renderSlot'
39+
import { shouldTrackInSlotRendering } from './helpers/renderSlot'
4040

4141
export const Fragment = (Symbol(__DEV__ ? 'Fragment' : undefined) as any) as {
4242
__isFragment: true
@@ -403,7 +403,7 @@ function _createVNode(
403403
normalizeChildren(vnode, children)
404404

405405
if (
406-
(shouldTrack > 0 || isRenderingTemplateSlot) &&
406+
(shouldTrack > 0 || shouldTrackInSlotRendering > 0) &&
407407
// avoid a block node from tracking itself
408408
!isBlockNode &&
409409
// has current parent block

0 commit comments

Comments
 (0)