fix(compiler): update v-if directive to use Comment instead of Empty (#208)

This commit is contained in:
Illya Klymov
2019-10-11 18:04:56 +03:00
committed by Evan You
parent 35d31a2ba2
commit 584ac88b54
9 changed files with 76 additions and 25 deletions

View File

@@ -211,6 +211,9 @@ export function generate(
// to provide the helper here.
if (ast.hoists.length) {
push(`const _${helperNameMap[CREATE_VNODE]} = Vue.createVNode\n`)
if (ast.helpers.includes(COMMENT)) {
push(`const _${helperNameMap[COMMENT]} = Vue.Comment\n`)
}
}
}
}
@@ -484,7 +487,7 @@ function genComment(node: CommentNode, context: CodegenContext) {
if (__DEV__) {
const { push, helper } = context
push(
`${helper(CREATE_VNODE)}(${helper(COMMENT)}, 0, ${JSON.stringify(
`${helper(CREATE_VNODE)}(${helper(COMMENT)}, null, ${JSON.stringify(
node.content
)})`,
node