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

🐛 BUG: Style tags are moved inside html tag when it exists #295

Closed
Princesseuh opened this issue Oct 20, 2022 · 2 comments
Closed

🐛 BUG: Style tags are moved inside html tag when it exists #295

Princesseuh opened this issue Oct 20, 2022 · 2 comments
Labels
ecosystem: compiler Issue is caused by a bug in the Astro compiler

Comments

@Princesseuh
Copy link
Member

Describe the Bug

Followup to #260, the compiler upgrade fixed it moving inside the body, but it now moves inside the html. That's still progress!

<html>
  <head>

  </head>
  <body>

  </body>
</html>

<style>

</style>

becomes

<html>
  <head> </head>
  <body> </body>

  <style></style>
</html>

Steps to Reproduce

See description

@mrienstra
Copy link
Contributor

mrienstra commented Oct 23, 2022

One of the tests added in withastro/compiler#541 (the PR that closed withastro/compiler#318, "BUG: [AST] style tag is moved inside the body tag") is internal/printer/printer_test.go#L2545-L2549:

{
  name:   "style after html",
  source: `<html><body><h1>Hello world!</h1></body></html><style></style>`,
  want:   []ASTNode{{Type: "element", Name: "html", Children: []ASTNode{{Type: "element", Name: "body", Children: []ASTNode{{Type: "element", Name: "h1", Children: []ASTNode{{Type: "text", Value: "Hello world!"}}}}}, {Type: "element", Name: "style"}}}},
},

The ASTNode looks like this when formatted:

{
  {Type: "element", Name: "html", Children: {
      {Type: "element", Name: "body", Children: {
          {Type: "element", Name: "h1", Children: {
              {Type: "text", Value: "Hello world!"}
            }
          }
        }
      },
      {Type: "element", Name: "style"}
    }
  }
}

... So looks like this is a withastro/compiler issue. I just opened withastro/compiler#585.

@Princesseuh
Copy link
Member Author

Fixed by the compiler upgrade in #297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem: compiler Issue is caused by a bug in the Astro compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants