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

@@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`the v-if/else-if/else branchs in Transition should ignore comments 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (_ctx) {
const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, createVNode: _createVNode, Fragment: _Fragment, Transition: _Transition, withCtx: _withCtx } = _Vue
return (_openBlock(), _createBlock(_Transition, null, {
default: _withCtx(() => [
a
? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"hey\\"))
: b
? (_openBlock(), _createBlock(\\"div\\", { key: 1 }, \\"hey\\"))
: (_openBlock(), _createBlock(\\"div\\", { key: 2 }, [
c
? (_openBlock(), _createBlock(\\"p\\", { key: 0 }))
: (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
_createCommentVNode(\\" this should not be ignored \\"),
_createVNode(\\"p\\")
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
]))
]),
_: 1 /* STABLE */
}))
}
}"
`;

View File

@@ -138,3 +138,21 @@ describe('compiler warnings', () => {
})
})
})
test('the v-if/else-if/else branchs in Transition should ignore comments', () => {
expect(
compile(`
<transition>
<div v-if="a">hey</div>
<!-- this should be ignored -->
<div v-else-if="b">hey</div>
<!-- this should be ignored -->
<div v-else>
<p v-if="c"/>
<!-- this should not be ignored -->
<p v-else/>
</div>
</transition>
`).code
).toMatchSnapshot()
})