Skip to content

Commit

Permalink
fix: error when evaluating falsey condition in a repeated template (#149
Browse files Browse the repository at this point in the history
)
  • Loading branch information
prevwong committed Mar 8, 2024
1 parent af6f9e4 commit 378baff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fast-singers-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rekajs/core': patch
---

Ignore nullish value when evaluating repeated templates
10 changes: 9 additions & 1 deletion packages/core/src/each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ export class EachDirectiveEvaluator {

newItems.add(itemHash);

views[i] = this.computeIteratorItem(itemHash, value, i);
const item = this.computeIteratorItem(itemHash, value, i);

// Ensure we don't return a null/undefined value
// This can happen if the template has an `if` condition which returns false
if (!item) {
continue;
}

views[i] = item;
}
}

Expand Down

0 comments on commit 378baff

Please sign in to comment.