Merge branch 'edison/fix/slotAndIfError' into edison/testVapor

This commit is contained in:
daiwei 2025-06-12 17:23:45 +08:00
commit a4f716f3c1
3 changed files with 40 additions and 1 deletions

View File

@ -134,3 +134,29 @@ export function render(_ctx) {
return n0
}"
`;
exports[`compiler: v-if > v-if + v-if / v-else[-if] 1`] = `
"import { setInsertionState as _setInsertionState, createIf as _createIf, template as _template } from 'vue';
const t0 = _template("<span>foo</span>")
const t1 = _template("<span>bar</span>")
const t2 = _template("<span>baz</span>")
const t3 = _template("<div></div>", true)
export function render(_ctx) {
const n8 = t3()
_setInsertionState(n8)
const n0 = _createIf(() => (_ctx.foo), () => {
const n2 = t0()
return n2
})
_setInsertionState(n8)
const n3 = _createIf(() => (_ctx.bar), () => {
const n5 = t1()
return n5
}, () => {
const n7 = t2()
return n7
})
return n8
}"
`;

View File

@ -215,6 +215,17 @@ describe('compiler: v-if', () => {
})
})
test('v-if + v-if / v-else[-if]', () => {
const { code } = compileWithVIf(
`<div>
<span v-if="foo">foo</span>
<span v-if="bar">bar</span>
<span v-else>baz</span>
</div>`,
)
expect(code).toMatchSnapshot()
})
test('comment between branches', () => {
const { code, ir } = compileWithVIf(`
<div v-if="ok"/>

View File

@ -68,8 +68,10 @@ export function processIf(
if (
siblings[i].operation &&
siblings[i].operation!.type === IRNodeTypes.IF
)
) {
lastIfNode = siblings[i].operation
break
}
}
}