Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): correctly track dynamic nodes in renderSlot #1911

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/runtime-core/src/helpers/renderSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { PatchFlags, SlotFlags } from '@vue/shared'
import { warn } from '../warning'

export let isRenderingTemplateSlot = false
export let shouldTrackInSlotRendering = 0

/**
* Compiler runtime helper for rendering `<slot/>`
Expand Down Expand Up @@ -39,7 +39,7 @@ export function renderSlot(
// invocation interfering with template-based block tracking, but in
// `renderSlot` we can be sure that it's template-based so we can force
// enable it.
isRenderingTemplateSlot = true
shouldTrackInSlotRendering++
const rendered = (openBlock(),
createBlock(
Fragment,
Expand All @@ -49,6 +49,6 @@ export function renderSlot(
? PatchFlags.STABLE_FRAGMENT
: PatchFlags.BAIL
))
isRenderingTemplateSlot = false
shouldTrackInSlotRendering--
return rendered
}
4 changes: 2 additions & 2 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { currentRenderingInstance } from './componentRenderUtils'
import { RendererNode, RendererElement } from './renderer'
import { NULL_DYNAMIC_COMPONENT } from './helpers/resolveAssets'
import { hmrDirtyComponents } from './hmr'
import { isRenderingTemplateSlot } from './helpers/renderSlot'
import { shouldTrackInSlotRendering } from './helpers/renderSlot'

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

if (
(shouldTrack > 0 || isRenderingTemplateSlot) &&
(shouldTrack > 0 || shouldTrackInSlotRendering > 0) &&
// avoid a block node from tracking itself
!isBlockNode &&
// has current parent block
Expand Down