Skip to content

Commit

Permalink
fix: issue with static template literal expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Aug 7, 2023
1 parent dc09704 commit 1235cf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/slow-books-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@marko/babel-utils": patch
"marko": patch
"@marko/translator-default": patch
---

Fix regression with static template literal expressions.
4 changes: 2 additions & 2 deletions packages/babel-utils/src/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ export function computeNode(node) {
return { value: test.value ? consequent.value : alternate.value };
}
case "TemplateLiteral": {
let value = node.quasis[0].cooked;
let value = node.quasis[0].value.cooked;
for (let i = 0; i < node.expressions.length; i++) {
const expr = computeNode(node.expressions[i]);
if (!expr) return;
value += expr.value + node.quasis[i + 1].cooked;
value += expr.value + node.quasis[i + 1].value.cooked;
}
return { value };
}
Expand Down

0 comments on commit 1235cf7

Please sign in to comment.