]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): correctly track dynamic nodes in renderSlot (#1911)
authorHcySunYang <HcySunYang@outlook.com>
Thu, 20 Aug 2020 13:37:26 +0000 (21:37 +0800)
committerGitHub <noreply@github.com>
Thu, 20 Aug 2020 13:37:26 +0000 (09:37 -0400)
packages/runtime-core/src/helpers/renderSlot.ts
packages/runtime-core/src/vnode.ts

index 0e4f09a3435edc173ea43269f6c6d0ed6499ab68..68e1edcbe3cc552693512b8754eee3ee01710f92 100644 (file)
@@ -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/>`
@@ -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,
@@ -49,6 +49,6 @@ export function renderSlot(
       ? PatchFlags.STABLE_FRAGMENT
       : PatchFlags.BAIL
   ))
-  isRenderingTemplateSlot = false
+  shouldTrackInSlotRendering--
   return rendered
 }
index 2f5a6bfaca188afd0a8d7910015ad0d54097bdf6..8eadedca27ff585f726620aef3c5acded89cae24 100644 (file)
@@ -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
@@ -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