Skip to content

Commit

Permalink
fix(#418): duplicate text
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jun 14, 2022
1 parent 2e9851e commit 6c00dac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rare-rivers-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/compiler': patch
---

Fix #418: duplicate text when only text
1 change: 0 additions & 1 deletion internal/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ func initialIM(p *parser) bool {
// It was all whitespace, so ignore it.
return true
}
p.addText(p.tok.Data)
case CommentToken:
p.doc.AppendChild(&Node{
Type: CommentNode,
Expand Down
7 changes: 7 additions & 0 deletions internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ func TestPrinter(t *testing.T) {
code: `${$$renderSlot($$result,$$slots["default"])}`,
},
},
{
name: "text only",
source: "Hello!",
want: want{
code: "Hello!",
},
},
{
name: "basic (frontmatter)",
source: `---
Expand Down
5 changes: 5 additions & 0 deletions internal/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func TestBasic(t *testing.T) {
`<img width="480" height="320">`,
[]TokenType{SelfClosingTagToken},
},
{
"text",
`Hello@`,
[]TokenType{TextToken},
},
{
"self-closing script",
`<script />`,
Expand Down

0 comments on commit 6c00dac

Please sign in to comment.