Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function render(_ctx) {
const n2 = _createComponentWithFallback(_component_Bar)
_withVaporDirectives(n2, [[_directive_hello, void 0, void 0, { world: true }]])
return n3
})
}, null, true)
return n0
}
}, true)
Expand Down Expand Up @@ -298,7 +298,7 @@ export function render(_ctx) {
const n1 = _createIf(() => (true), () => {
const n3 = t0()
return n3
})
}, null, true)
_renderEffect(() => _setProp(n4, "disabled", _ctx.foo))
return n6
}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function render(_ctx) {
const n2 = t0()
_setTemplateRef(n2, "foo")
return n2
})
}, null, true)
return n0
}"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ export function render(_ctx) {
}, () => _createIf(() => (_ctx.orNot), () => {
const n4 = t1()
return n4
}, () => {
const n7 = t2()
}, () => _createIf(() => (false), () => {
const n7 = t1()
return n7
}))
}, () => {
const n10 = t2()
return n10
}, true)))
return n0
}"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export function render(_ctx) {
}, () => {
const n5 = _createComponentWithFallback(_component_Bar)
return n5
})
}, true)
return n6
}"
`;
Expand Down
11 changes: 7 additions & 4 deletions packages/compiler-vapor/__tests__/transforms/vIf.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('compiler: v-if', () => {

test('v-if + v-else-if + v-else', () => {
const { code, ir } = compileWithVIf(
`<div v-if="ok"/><p v-else-if="orNot"/><template v-else>fine</template>`,
`<div v-if="ok"/><p v-else-if="orNot"/><p v-else-if="false"/><template v-else>fine</template>`,
)
expect(code).matchSnapshot()
expect(ir.template).toEqual(['<div></div>', '<p></p>', 'fine'])
Expand All @@ -206,9 +206,12 @@ describe('compiler: v-if', () => {
},
},
negative: {
type: IRNodeTypes.BLOCK,
dynamic: {
children: [{ template: 2 }],
type: IRNodeTypes.IF,
negative: {
type: IRNodeTypes.BLOCK,
dynamic: {
children: [{ template: 2 }],
},
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion packages/compiler-vapor/src/transforms/vIf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export function processIf(
id: -1,
condition: dir.exp!,
positive: branch,
once: context.inVOnce,
once:
context.inVOnce ||
isStaticExpression(dir.exp!, context.options.bindingMetadata),
}
}

Expand Down
6 changes: 6 additions & 0 deletions packages/compiler-vapor/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export function isStaticExpression(
if (node.ast) {
return isConstantNode(node.ast, bindings)
} else if (node.ast === null) {
if (
!node.isStatic &&
(node.content === 'true' || node.content === 'false')
) {
return true
}
const type = bindings[node.content]
return type === BindingTypes.LITERAL_CONST
}
Expand Down
Loading