Skip to content

Commit 2bdb4bb

Browse files
authored
Revert "Fix expressions within td exitLiteralIM tracking (#885)" (#889)
1 parent a4e3c37 commit 2bdb4bb

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

.changeset/stupid-rats-cough.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/compiler': patch
3+
---
4+
5+
Revert table related parsing change as it resulted in a regression

internal/parser.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -2176,10 +2176,9 @@ func inRowIM(p *parser) bool {
21762176
func inCellIM(p *parser) bool {
21772177
switch p.tok.Type {
21782178
case StartExpressionToken:
2179-
p.exitLiteralIM = getExitLiteralFunc(p)
21802179
p.addExpression()
21812180
p.afe = append(p.afe, &scopeMarker)
2182-
p.originalIM = inCellIM
2181+
p.originalIM = inBodyIM
21832182
p.im = inExpressionIM
21842183
return true
21852184
case EndExpressionToken:

internal/printer/printer_test.go

+44-7
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,50 @@ const value = 'test';
19591959
code: `${bool && $$render` + BACKTICK + `${$$maybeRenderHead($$result)}<textarea>${value}</textarea>` + BACKTICK + `} ${!bool && $$render` + BACKTICK + `<input>` + BACKTICK + `}`,
19601960
},
19611961
},
1962+
{
1963+
name: "table simple case",
1964+
source: `---
1965+
const content = "lol";
1966+
---
1967+
1968+
<html>
1969+
<body>
1970+
<table>
1971+
<tr>
1972+
<td>{content}</td>
1973+
</tr>
1974+
{
1975+
(
1976+
<tr>
1977+
<td>1</td>
1978+
</tr>
1979+
)
1980+
}
1981+
</table>Hello
1982+
</body>
1983+
</html>
1984+
`,
1985+
want: want{
1986+
frontmatter: []string{"", `const content = "lol";`},
1987+
// TODO: This output is INCORRECT, but we're testing a regression
1988+
// The trailing text (`Hello`) shouldn't be consumed by the <table> element!
1989+
code: `<html>
1990+
${$$maybeRenderHead($$result)}<body>
1991+
<table>
1992+
<tr>
1993+
<td>${content}</td>
1994+
</tr>
1995+
${
1996+
(
1997+
$$render` + BACKTICK + `<tr>
1998+
<td>1</td>
1999+
</tr>` + BACKTICK + `
2000+
)
2001+
} Hello
2002+
</table></body>
2003+
</html>`,
2004+
},
2005+
},
19622006
{
19632007
name: "table expressions (no implicit tbody)",
19642008
source: `---
@@ -1977,13 +2021,6 @@ const items = ["Dog", "Cat", "Platipus"];
19772021
code: `${$$maybeRenderHead($$result)}<table><caption>${title}</caption><tr><td>Hello</td></tr></table>`,
19782022
},
19792023
},
1980-
{
1981-
name: "table expression with trailing div",
1982-
source: `<table><tr><td>{title}</td></tr></table><div>Div</div>`,
1983-
want: want{
1984-
code: `${$$maybeRenderHead($$result)}<table><tr><td>${title}</td></tr></table><div>Div</div>`,
1985-
},
1986-
},
19872024
{
19882025
name: "tbody expressions",
19892026
source: `---

0 commit comments

Comments
 (0)