Skip to content

Commit

Permalink
Fix regression in generics logic (#491)
Browse files Browse the repository at this point in the history
* fix: regression in generics logic

* chore: add changeset

Co-authored-by: Nate Moore <nate@astro.build>
  • Loading branch information
natemoo-re and natemoo-re authored Aug 5, 2022
1 parent 73e07fe commit 79376f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fast-rules-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/compiler': patch
---

Fix regression with expression rendering
7 changes: 7 additions & 0 deletions internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ func TestPrinter(t *testing.T) {
code: "Hello!",
},
},
{
name: "custom-element",
source: "{show && <client-only-element></client-only-element>}",
want: want{
code: "${show && $$render`${$$renderComponent($$result,'client-only-element','client-only-element',{})}`}",
},
},
{
name: "attribute with template literal",
source: "<a :href=\"`/home`\">Home</a>",
Expand Down
2 changes: 1 addition & 1 deletion internal/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ func (z *Tokenizer) readStartTag() TokenType {
originalLen := len(text)
// If this "StartTagToken" does not include any spaces between it and the end of the expression
// we can roughly assume it is a TypeScript generic rather than an element. Rough but it works!
if len(strings.TrimRightFunc(text, unicode.IsSpace)) == originalLen {
if len(text) != 0 && len(strings.TrimRightFunc(text, unicode.IsSpace)) == originalLen {
return TextToken
}
}
Expand Down

0 comments on commit 79376f3

Please sign in to comment.