mirror of https://github.com/vuejs/core.git
fix(compiler-core): fix parsing error on comments between v-if in prod
close #6843
This commit is contained in:
parent
64e6d9221d
commit
dd3354c4c7
|
@ -712,6 +712,27 @@ describe('compiler: v-if', () => {
|
|||
expect(b1.children[3].type).toBe(NodeTypes.ELEMENT)
|
||||
expect((b1.children[3] as ElementNode).tag).toBe(`p`)
|
||||
})
|
||||
|
||||
// #6843
|
||||
test('should parse correctly with comments: true in prod', () => {
|
||||
__DEV__ = false
|
||||
parseWithIfTransform(
|
||||
`
|
||||
<template v-if="ok">
|
||||
<!--comment1-->
|
||||
<div v-if="ok2">
|
||||
<!--comment2-->
|
||||
</div>
|
||||
<!--comment3-->
|
||||
<b v-else/>
|
||||
<!--comment4-->
|
||||
<p/>
|
||||
</template>
|
||||
`,
|
||||
{ comments: true }
|
||||
)
|
||||
__DEV__ = true
|
||||
})
|
||||
})
|
||||
|
||||
test('v-on with v-if', () => {
|
||||
|
|
|
@ -129,9 +129,9 @@ export function processIf(
|
|||
let i = siblings.indexOf(node)
|
||||
while (i-- >= -1) {
|
||||
const sibling = siblings[i]
|
||||
if (__DEV__ && sibling && sibling.type === NodeTypes.COMMENT) {
|
||||
if (sibling && sibling.type === NodeTypes.COMMENT) {
|
||||
context.removeNode(sibling)
|
||||
comments.unshift(sibling)
|
||||
__DEV__ && comments.unshift(sibling)
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue