diff --git a/packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts b/packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts index e4d6d24e..3b2c70de 100644 --- a/packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts +++ b/packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts @@ -32,6 +32,24 @@ describe('compiler: expression transform', () => { }) }) + test('empty interpolation', () => { + const node = parseWithExpressionTransform(`{{}}`) as InterpolationNode + const node2 = parseWithExpressionTransform(`{{ }}`) as InterpolationNode + const node3 = parseWithExpressionTransform( + `
{{ }}
` + ) as ElementNode + + const objectToBeMatched = { + type: NodeTypes.SIMPLE_EXPRESSION, + content: `` + } + expect(node.content).toMatchObject(objectToBeMatched) + expect(node2.content).toMatchObject(objectToBeMatched) + expect((node3.children[0] as InterpolationNode).content).toMatchObject( + objectToBeMatched + ) + }) + test('interpolation (children)', () => { const el = parseWithExpressionTransform( `
{{ foo }}
` diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index 84bb35ef..2894e33e 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -77,7 +77,7 @@ export function processExpression( // function params asParams: boolean = false ): ExpressionNode { - if (!context.prefixIdentifiers) { + if (!context.prefixIdentifiers || !node.content.trim()) { return node }