Skip to content

Commit

Permalink
Revert "Fix expressions within td exitLiteralIM tracking (#885)" (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Nov 14, 2023
1 parent a4e3c37 commit 2bdb4bb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
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

0 comments on commit 2bdb4bb

Please sign in to comment.