Skip to content

Commit

Permalink
feat: error on empty placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Oct 13, 2021
1 parent 6188917 commit 6db2af0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/states/PLACEHOLDER.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export const PLACEHOLDER = Parser.createState({
var newExpression = this.notifiers.notifyPlaceholder(placeholder);
placeholder.value = newExpression;
}

if (!placeholder.value) {
this.notifyError(
placeholder.pos,
"PLACEHOLDER_EXPRESSION_REQUIRED",
"Invalid placeholder, the expression cannot be missing"
);
}
},

return(childState, childPart, placeholder) {
Expand Down
1 change: 1 addition & 0 deletions test/autotest/placeholder-empty/expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error:"Invalid placeholder, the expression cannot be missing" (code: "PLACEHOLDER_EXPRESSION_REQUIRED")
1 change: 1 addition & 0 deletions test/autotest/placeholder-empty/input.htmljs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<${}/>

0 comments on commit 6db2af0

Please sign in to comment.