Skip to content

Commit

Permalink
fix: v-else branch virtual code missing
Browse files Browse the repository at this point in the history
close #1694
  • Loading branch information
johnsoncodehk committed Aug 10, 2022
1 parent 607fe6c commit b7db773
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vue-language-core/src/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,14 @@ export function generate(
blockConditions.push(branch.condition.content);
addedBlockCondition = true;
}
}

tsCodeGen.addText(` {\n`);
writeInterpolationVarsExtraCompletion();
for (const childNode of branch.children) {
visitNode(childNode, parentEl);
}
tsCodeGen.addText('}\n');
tsCodeGen.addText(` {\n`);
writeInterpolationVarsExtraCompletion();
for (const childNode of branch.children) {
visitNode(childNode, parentEl);
}
tsCodeGen.addText('}\n');

if (addedBlockCondition) {
blockConditions[blockConditions.length - 1] = `!(${blockConditions[blockConditions.length - 1]})`;
Expand Down
13 changes: 13 additions & 0 deletions packages/vue-test-workspace/vue-tsc/v-if/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
const ifVar = {} as boolean;
const elseIfVar = {} as boolean;
const ifExp = 1;
const ifElseExp = 1;
const elseExp = 1;
</script>

<template>
<div v-if="ifVar">{{ ifExp }}</div>
<div v-else-if="elseIfVar">{{ ifElseExp }}</div>
<div v-else>{{ elseExp }}</div>
</template>

0 comments on commit b7db773

Please sign in to comment.