Skip to content

Commit

Permalink
fix: don't self-close empty script tags (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
brentd authored Jun 20, 2022
1 parent 06fdb56 commit c54832e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parser/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (e RawElement) Write(w io.Writer, indent int) error {
return err
}
}
if _, err := w.Write([]byte("/>")); err != nil {
if _, err := w.Write([]byte(">")); err != nil {
return err
}
// Contents.
Expand Down
19 changes: 19 additions & 0 deletions parser/v2/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ templ input(value, validation string) {
<wbr/>
}
`,
},
{
name: "script tags are not converted to self-closing elements",
input: ` // first line removed to make indentation clear in Go code
package test
templ input(value, validation string) {
<script src="https://example.com/myscript.js"></script>
}
`,
expected: `// first line removed to make indentation clear in Go code
package test
templ input(value, validation string) {
<script src="https://example.com/myscript.js"></script>
}
`,
},
{
Expand Down

0 comments on commit c54832e

Please sign in to comment.