Skip to content

Commit

Permalink
fix(#531): handle slots before <head>
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Oct 4, 2022
1 parent c27a7b5 commit f6390ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,14 @@ func beforeHeadIM(p *parser) bool {
return true
case StartTagToken:
switch p.tok.DataAtom {
case a.Slot:
p.addElement()
if p.hasSelfClosingToken {
p.addLoc()
p.oe.pop()
p.acknowledgeSelfClosingTag()
}
return true
case a.Head:
p.addElement()
p.head = p.top()
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 @@ -109,6 +109,13 @@ func TestPrinter(t *testing.T) {
code: `<html><head><title>Ah</title>` + RENDER_HEAD_RESULT + `</head></html>`,
},
},
{
name: "head inside slot",
source: `<html><slot><head></head></html>`,
want: want{
code: `<html>${$$renderSlot($$result,$$slots["default"],$$render` + BACKTICK + `<head>` + RENDER_HEAD_RESULT + `</head>` + BACKTICK + `)}</html>`,
},
},
{
name: "head slot",
source: `<html><head><slot /></html>`,
Expand Down

0 comments on commit f6390ce

Please sign in to comment.