|
|
@@ -36,7 +36,6 @@ import { currentRenderingInstance } from './componentRenderUtils'
|
|
|
import { RendererNode, RendererElement } from './renderer'
|
|
|
import { NULL_DYNAMIC_COMPONENT } from './helpers/resolveAssets'
|
|
|
import { hmrDirtyComponents } from './hmr'
|
|
|
-import { shouldTrackInSlotRendering } from './helpers/renderSlot'
|
|
|
|
|
|
export const Fragment = (Symbol(__DEV__ ? 'Fragment' : undefined) as any) as {
|
|
|
__isFragment: true
|
|
|
@@ -153,7 +152,7 @@ export interface VNode<
|
|
|
// can divide a template into nested blocks, and within each block the node
|
|
|
// structure would be stable. This allows us to skip most children diffing
|
|
|
// and only worry about the dynamic nodes (indicated by patch flags).
|
|
|
-const blockStack: (VNode[] | null)[] = []
|
|
|
+export const blockStack: (VNode[] | null)[] = []
|
|
|
let currentBlock: VNode[] | null = null
|
|
|
|
|
|
/**
|
|
|
@@ -176,6 +175,11 @@ export function openBlock(disableTracking = false) {
|
|
|
blockStack.push((currentBlock = disableTracking ? null : []))
|
|
|
}
|
|
|
|
|
|
+export function closeBlock() {
|
|
|
+ blockStack.pop()
|
|
|
+ currentBlock = blockStack[blockStack.length - 1] || null
|
|
|
+}
|
|
|
+
|
|
|
// Whether we should be tracking dynamic child nodes inside a block.
|
|
|
// Only tracks when this value is > 0
|
|
|
// We are not using a simple boolean because this value may need to be
|
|
|
@@ -227,8 +231,7 @@ export function createBlock(
|
|
|
// save current block children on the block vnode
|
|
|
vnode.dynamicChildren = currentBlock || EMPTY_ARR
|
|
|
// close block
|
|
|
- blockStack.pop()
|
|
|
- currentBlock = blockStack[blockStack.length - 1] || null
|
|
|
+ closeBlock()
|
|
|
// a block is always going to be patched, so track it as a child of its
|
|
|
// parent block
|
|
|
if (currentBlock) {
|
|
|
@@ -403,7 +406,7 @@ function _createVNode(
|
|
|
normalizeChildren(vnode, children)
|
|
|
|
|
|
if (
|
|
|
- (shouldTrack > 0 || shouldTrackInSlotRendering > 0) &&
|
|
|
+ shouldTrack > 0 &&
|
|
|
// avoid a block node from tracking itself
|
|
|
!isBlockNode &&
|
|
|
// has current parent block
|