Skip to content

Commit

Permalink
fix infinite loop on empty expression
Browse files Browse the repository at this point in the history
  • Loading branch information
davidodenwald committed Mar 3, 2024
1 parent 9418103 commit 866d21c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const parse: Parser<Node>["parse"] = (text) => {
nodes: root.nodes,
};

if (comment || ignoreBlock) {
if (comment != undefined || ignoreBlock != undefined) {
root.content = replaceAt(
root.content,
placeholder,
Expand All @@ -86,7 +86,7 @@ export const parse: Parser<Node>["parse"] = (text) => {
i += match.index + placeholder.length;
}

if (expression) {
if (expression != undefined) {
const delimiter = (match.groups.startDelimiterEx ||
match.groups.endDelimiterEx) as Delimiter;

Expand All @@ -106,7 +106,7 @@ export const parse: Parser<Node>["parse"] = (text) => {
i += match.index + placeholder.length;
}

if (statement) {
if (statement != undefined) {
const keyword = match.groups.keyword;
const delimiter = (match.groups.startDelimiter ||
match.groups.endDelimiter) as Delimiter;
Expand Down
1 change: 1 addition & 0 deletions test/cases/expression_empty/expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>{{ }}</div>
1 change: 1 addition & 0 deletions test/cases/expression_empty/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>{{ }}</div>

0 comments on commit 866d21c

Please sign in to comment.