Skip to content

Commit 6ada1b3

Browse files
author
Guilherme de Oliveira
committed
fix: handle null emits
1 parent 0fff989 commit 6ada1b3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/interface.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,16 @@ export default defineComponent({
7070
};
7171
7272
function compute() {
73-
return props.template.replace(/{{.*?}}/g, (match) => {
73+
const computedValue = props.template.replace(/{{.*?}}/g, (match) => {
7474
const expression = match.slice(2, -2).trim();
7575
return parseExpression(expression, values.value);
7676
});
77+
78+
if (!computedValue) {
79+
return null;
80+
}
81+
82+
return computedValue;
7783
}
7884
},
7985
});

src/operations.ts

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export function parseExpression(exp: string, values: Record<string, any>): any {
1010
const { op, a, b } = opMatch;
1111
const valueA = parseExpression(a, values);
1212

13+
if (!valueA) {
14+
return '';
15+
}
16+
1317
// unary operators
1418
if (b === null) {
1519
// type conversion

0 commit comments

Comments
 (0)