fix(compiler-core): avoid prefixing empty interpolations (#290)
This commit is contained in:
parent
555e3be69d
commit
3385480ba7
@ -32,6 +32,24 @@ describe('compiler: expression transform', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('empty interpolation', () => {
|
||||||
|
const node = parseWithExpressionTransform(`{{}}`) as InterpolationNode
|
||||||
|
const node2 = parseWithExpressionTransform(`{{ }}`) as InterpolationNode
|
||||||
|
const node3 = parseWithExpressionTransform(
|
||||||
|
`<div>{{ }}</div>`
|
||||||
|
) 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)', () => {
|
test('interpolation (children)', () => {
|
||||||
const el = parseWithExpressionTransform(
|
const el = parseWithExpressionTransform(
|
||||||
`<div>{{ foo }}</div>`
|
`<div>{{ foo }}</div>`
|
||||||
|
@ -77,7 +77,7 @@ export function processExpression(
|
|||||||
// function params
|
// function params
|
||||||
asParams: boolean = false
|
asParams: boolean = false
|
||||||
): ExpressionNode {
|
): ExpressionNode {
|
||||||
if (!context.prefixIdentifiers) {
|
if (!context.prefixIdentifiers || !node.content.trim()) {
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user