Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix expressions within td exitLiteralIM tracking (#885)" #889

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-rats-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/compiler': patch
---

Revert table related parsing change as it resulted in a regression
3 changes: 1 addition & 2 deletions internal/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2176,10 +2176,9 @@ func inRowIM(p *parser) bool {
func inCellIM(p *parser) bool {
switch p.tok.Type {
case StartExpressionToken:
p.exitLiteralIM = getExitLiteralFunc(p)
p.addExpression()
p.afe = append(p.afe, &scopeMarker)
p.originalIM = inCellIM
p.originalIM = inBodyIM
p.im = inExpressionIM
return true
case EndExpressionToken:
Expand Down
51 changes: 44 additions & 7 deletions internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,50 @@ const value = 'test';
code: `${bool && $$render` + BACKTICK + `${$$maybeRenderHead($$result)}<textarea>${value}</textarea>` + BACKTICK + `} ${!bool && $$render` + BACKTICK + `<input>` + BACKTICK + `}`,
},
},
{
name: "table simple case",
source: `---
const content = "lol";
---

<html>
<body>
<table>
<tr>
<td>{content}</td>
</tr>
{
(
<tr>
<td>1</td>
</tr>
)
}
</table>Hello
</body>
</html>
`,
want: want{
frontmatter: []string{"", `const content = "lol";`},
// TODO: This output is INCORRECT, but we're testing a regression
// The trailing text (`Hello`) shouldn't be consumed by the <table> element!
code: `<html>
${$$maybeRenderHead($$result)}<body>
<table>
<tr>
<td>${content}</td>
</tr>
${
(
$$render` + BACKTICK + `<tr>
<td>1</td>
</tr>` + BACKTICK + `
)
} Hello
</table></body>
</html>`,
},
},
{
name: "table expressions (no implicit tbody)",
source: `---
Expand All @@ -1977,13 +2021,6 @@ const items = ["Dog", "Cat", "Platipus"];
code: `${$$maybeRenderHead($$result)}<table><caption>${title}</caption><tr><td>Hello</td></tr></table>`,
},
},
{
name: "table expression with trailing div",
source: `<table><tr><td>{title}</td></tr></table><div>Div</div>`,
want: want{
code: `${$$maybeRenderHead($$result)}<table><tr><td>${title}</td></tr></table><div>Div</div>`,
},
},
{
name: "tbody expressions",
source: `---
Expand Down