fix: generate v-if fallback comment as block

This commit is contained in:
Evan You
2019-10-24 21:19:02 -04:00
parent 7b637319a8
commit ed29af7bea
5 changed files with 22 additions and 10 deletions

View File

@@ -258,8 +258,15 @@ export function createTextVNode(text: string = ' ', flag: number = 0): VNode {
return createVNode(Text, null, text, flag)
}
export function createCommentVNode(text: string = ''): VNode {
return createVNode(Comment, null, text)
export function createCommentVNode(
text: string = '',
// when used as the v-else branch, the comment node must be created as a
// block to ensure correct updates.
asBlock: boolean = false
): VNode {
return asBlock
? createBlock(Comment, null, text)
: createVNode(Comment, null, text)
}
export function normalizeVNode(child: VNodeChild): VNode {