Skip to content

Commit

Permalink
feat: support component in v-if
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj committed Feb 3, 2024
1 parent a0388b1 commit a6cdef8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/v-if.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function transformVIf(
s.remove(start!, consequent.start!)
}
else {
overwrite(start, consequent.start!, `<template${directive}>${isJSXExpressionConsequent ? '' : '{{'}`, s)
overwrite(start, consequent.start!, `<template${directive}>${isJSXExpressionConsequent ? '' : '<component :is="__createTextVNode('}`, s)
}

if (isJSXElement(alternate)) {
Expand All @@ -37,7 +37,7 @@ export function transformVIf(
s.remove(consequent.end!, alternate.start!)
}
else {
overwrite(consequent.end!, alternate.start!, `${isJSXExpressionConsequent ? '' : '}}'}</template>`, s)
overwrite(consequent.end!, alternate.start!, `${isJSXExpressionConsequent ? '' : ')" />'}</template>`, s)
}
s.remove(alternate.end!, end)
}
Expand All @@ -50,11 +50,11 @@ export function transformVIf(
alternate.start!,
`${isJSXElementConsequent
? ''
: `${isJSXExpressionConsequent ? '' : '}}'
}</template>`}<template v-else>${isJSXExpressionAlternate ? '' : '{{'}`,
: `${isJSXExpressionConsequent ? '' : ')" />'
}</template>`}<template v-else>${isJSXExpressionAlternate ? '' : '<component :is="__createTextVNode('}`,
s,
)
overwrite(alternate.end!, end, `${isJSXExpressionAlternate ? '' : '}}'}</template>`, s)
overwrite(alternate.end!, end, `${isJSXExpressionAlternate ? '' : ')" />'}</template>`, s)
}
else {
s.remove(consequent.end!, alternate.start!)
Expand Down

0 comments on commit a6cdef8

Please sign in to comment.