Skip to content

Commit

Permalink
[TSX] escape more invalid characters (#827)
Browse files Browse the repository at this point in the history
* fix(#583): escape more invalid strings

* fix: handle edge case in failing tests

* chore: add changeset
  • Loading branch information
natemoo-re authored Jul 13, 2023
1 parent 1497372 commit 34fcf01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/few-cats-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/compiler': patch
---

[TSX] escape additional invalid characters
2 changes: 1 addition & 1 deletion internal/printer/print-to-tsx.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ declare const Astro: Readonly<import('astro').AstroGlobal<%s>>`, props.Ident)
p.print("}}\n")
p.addSourceMapping(loc.Loc{Start: n.Loc[0].Start + len(n.Data)})
return
} else if strings.ContainsAny(n.Data, "{}") {
} else if strings.ContainsAny(n.Data, "{}<>'\"") && n.Data[0] != '<' {
p.addNilSourceMapping()
p.print("{`")
p.printTextWithSourcemap(escapeText(n.Data), n.Loc[0])
Expand Down

0 comments on commit 34fcf01

Please sign in to comment.