diff --git a/packages/compiler-core/src/transforms/vIf.ts b/packages/compiler-core/src/transforms/vIf.ts index 6109558846f..076ce5812a4 100644 --- a/packages/compiler-core/src/transforms/vIf.ts +++ b/packages/compiler-core/src/transforms/vIf.ts @@ -116,6 +116,13 @@ export function processIf( comments.unshift(sibling) continue } + // check for empty text nodes + if (sibling && sibling.type === NodeTypes.TEXT) { + if (!/[^\t\r\n\f ]/.test(sibling.content)) { + context.removeNode(sibling) + continue + } + } if (sibling && sibling.type === NodeTypes.IF) { // move the node to the if node's branches context.removeNode()