fix(compiler-core): always compile Teleport and Suspense as blocks

This commit is contained in:
Evan You 2020-07-28 11:12:43 -04:00
parent b3b65b4058
commit fbf865d9d4
2 changed files with 5 additions and 6 deletions

View File

@ -35,7 +35,8 @@ import {
MERGE_PROPS, MERGE_PROPS,
TO_HANDLERS, TO_HANDLERS,
TELEPORT, TELEPORT,
KEEP_ALIVE KEEP_ALIVE,
SUSPENSE
} from '../runtimeHelpers' } from '../runtimeHelpers'
import { import {
getInnerRange, getInnerRange,
@ -89,6 +90,8 @@ export const transformElement: NodeTransform = (node, context) => {
let shouldUseBlock = let shouldUseBlock =
// dynamic component may resolve to plain elements // dynamic component may resolve to plain elements
isDynamicComponent || isDynamicComponent ||
vnodeTag === TELEPORT ||
vnodeTag === SUSPENSE ||
(!isComponent && (!isComponent &&
// <svg> and <foreignObject> must be forced into blocks so that block // <svg> and <foreignObject> must be forced into blocks so that block
// updates inside get proper isSVG flag at runtime. (#639, #643) // updates inside get proper isSVG flag at runtime. (#639, #643)

View File

@ -411,11 +411,7 @@ function _createVNode(
// the EVENTS flag is only for hydration and if it is the only flag, the // the EVENTS flag is only for hydration and if it is the only flag, the
// vnode should not be considered dynamic due to handler caching. // vnode should not be considered dynamic due to handler caching.
patchFlag !== PatchFlags.HYDRATE_EVENTS && patchFlag !== PatchFlags.HYDRATE_EVENTS &&
(patchFlag > 0 || (patchFlag > 0 || shapeFlag & ShapeFlags.COMPONENT)
shapeFlag & ShapeFlags.SUSPENSE ||
shapeFlag & ShapeFlags.TELEPORT ||
shapeFlag & ShapeFlags.STATEFUL_COMPONENT ||
shapeFlag & ShapeFlags.FUNCTIONAL_COMPONENT)
) { ) {
currentBlock.push(vnode) currentBlock.push(vnode)
} }