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

<article> tag included in <head> when parsing page fragment #211

Open
alterae opened this issue Sep 25, 2024 · 0 comments
Open

<article> tag included in <head> when parsing page fragment #211

alterae opened this issue Sep 25, 2024 · 0 comments

Comments

@alterae
Copy link

alterae commented Sep 25, 2024

Expected behavior

Given a partial HTML input like the following:

<meta name="layout" content="main.php">
<article>
  <h1>Foo</h1>
  <p>Bar, baz, etc...</p>
</article>

I would expect DiDOM to model it as follows:

<html> <!-- added by DiDOM -->
  <head> <!-- added by DiDOM -->
    <meta name="layout" content="main.php">
  </head>
  <body> <!-- added by DiDOM -->
    <article>
       <!-- ... -->
    </article>
  </body>
</html>

This would be consistent with its behavior when the <article> tag is replaced with a <div>, or when the <article> tag is placed immediately after the <h1> instead of containing it. This would also be valid HTML.

Actual behavior

In practice, DiDOM sees the following structure in our example markup.

<html> <!-- added by DiDOM -->
  <head> <!-- added by DiDOM -->
    <meta name="layout" content="main.php">
    <article> <!-- UH-OH! This should not be here! -->
      <h1>...</h1>
      <p>...</p>
    </article>
  </head>
  <body> <!-- added by DiDOM -->
  </body>
</html>

This seems like a bug, as an <article> tag as a direct child of the document <head> is not valid HTML.

While it is possible to work around this behavior, it is inconvenient and this behavior is both surprising and incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant