fix(compiler-dom): comments in the v-if branchs should be ignored when used in Transition (#3622)

fix #3619
This commit is contained in:
HcySunYang
2021-05-25 05:10:29 +08:00
committed by GitHub
parent 3ef1fcc859
commit 7c74feb3dc
3 changed files with 58 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ import {
OPEN_BLOCK,
CREATE_VNODE
} from '../runtimeHelpers'
import { injectProp, findDir, findProp } from '../utils'
import { injectProp, findDir, findProp, isBuiltInType } from '../utils'
import { PatchFlags, PatchFlagNames } from '@vue/shared'
export const transformIf = createStructuralDirectiveTransform(
@@ -146,7 +146,16 @@ export function processIf(
// move the node to the if node's branches
context.removeNode()
const branch = createIfBranch(node, dir)
if (__DEV__ && comments.length) {
if (
__DEV__ &&
comments.length &&
// #3619 ignore comments if the v-if is direct child of <transition>
!(
context.parent &&
context.parent.type === NodeTypes.ELEMENT &&
isBuiltInType(context.parent.tag, 'transition')
)
) {
branch.children = [...comments, ...branch.children]
}