File tree Expand file tree Collapse file tree 3 files changed +41
-10
lines changed
packages/compiler/test/basic Expand file tree Collapse file tree 3 files changed +41
-10
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @astrojs/compiler ' : patch
3+ ---
4+
5+ Fix regression introduced by https://github.com/withastro/compiler/pull/617
Original file line number Diff line number Diff line change @@ -686,6 +686,7 @@ func beforeHTMLIM(p *parser) bool {
686686 }
687687 if p .literal {
688688 p .im = inLiteralIM
689+ p .originalIM = beforeHTMLIM
689690 return false
690691 }
691692 case EndTagToken :
@@ -784,10 +785,8 @@ func inHeadIM(p *parser) bool {
784785 // Allow components in Head
785786 if isComponent (p .tok .Data ) || isFragment (p .tok .Data ) {
786787 p .im = inLiteralIM
787- oe := len (p .oe )
788- p .exitLiteralIM = func () bool {
789- return len (p .oe ) == oe
790- }
788+ p .originalIM = inHeadIM
789+ p .exitLiteralIM = getExitLiteralFunc (p )
791790 return false
792791 }
793792 switch p .tok .DataAtom {
@@ -1116,6 +1115,7 @@ func inBodyIM(p *parser) bool {
11161115 // if literal and we only have html and body open
11171116 if p .literal {
11181117 p .im = inLiteralIM
1118+ p .originalIM = inBodyIM
11191119 return false
11201120 }
11211121 // It's possible we were moved here from inHeadIM
@@ -2435,6 +2435,7 @@ func afterBodyIM(p *parser) bool {
24352435 case EndTagToken :
24362436 if p .literal {
24372437 p .im = inLiteralIM
2438+ p .originalIM = afterBodyIM
24382439 return false
24392440 }
24402441 if p .tok .DataAtom == a .Html {
@@ -2755,13 +2756,9 @@ func ignoreTheRemainingTokens(p *parser) bool {
27552756
27562757// Generate a function that will exit `inLiteralIM` when all expressions are closed
27572758func getExitLiteralFunc (p * parser ) func () bool {
2759+ oe := len (p .oe )
27582760 return func () bool {
2759- for _ , n := range p .oe {
2760- if n .Expression {
2761- return false
2762- }
2763- }
2764- return true
2761+ return len (p .oe ) == oe
27652762 }
27662763}
27672764
Original file line number Diff line number Diff line change 1+ import { test } from 'uvu' ;
2+ import * as assert from 'uvu/assert' ;
3+ import { transform } from '@astrojs/compiler' ;
4+
5+ const FIXTURE = `
6+ <!DOCTYPE html>
7+ <html lang="en">
8+ <head>
9+ <TestHead />
10+ <title>document</title>
11+ </head>
12+ <body>
13+ <main>
14+ <h1>Welcome to <span class="text-gradient">Astro</span></h1>
15+ </main>
16+ </body>
17+ </html>
18+ ` ;
19+
20+ let result ;
21+ test . before ( async ( ) => {
22+ result = await transform ( FIXTURE ) ;
23+ } ) ;
24+
25+ test ( 'has body in output' , ( ) => {
26+ assert . match ( result . code , '<body>' , 'Expected output to contain body element!' ) ;
27+ } ) ;
28+
29+ test . run ( ) ;
You can’t perform that action at this time.
0 commit comments