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

preact/debug: Incorrect table warning #4111

Closed
1 task done
marvinhagemeister opened this issue Aug 20, 2023 · 5 comments · Fixed by #4375
Closed
1 task done

preact/debug: Incorrect table warning #4111

marvinhagemeister opened this issue Aug 20, 2023 · 5 comments · Fixed by #4375
Labels

Comments

@marvinhagemeister
Copy link
Member

marvinhagemeister commented Aug 20, 2023

  • Check if updating to the latest Preact version resolves the issue

Describe the bug
preact/debug throws a warning when the code is valid HTML code. That's unexpected.

To Reproduce

import "preact/debug";
import { render } from "preact";

render(<table><tr /></table>, document.getElementById("app"));

Expected behavior
No warning, it's a valid HTML structure. Iirc there are some rules regarding tbody when it must be present and not. I don't know them at the top of my head, best to check with the spec.

@adamgreg
Copy link

I originally noticed this with a complete table structure, including thead and tbody. I was also getting warnings about those elements needing a table parent (which they had).

@JoviDeCroock
Copy link
Member

@nmain
Copy link

nmain commented Aug 23, 2023

This vdom structure does result in HTML which doesn't match the vdom and is modified during hydration.

See this (admittedly canned) example where there's a flash of styling change when hydration happens: https://codesandbox.io/s/busy-williams-scnwzw?file=/src/index.mjs

@marvinhagemeister
Copy link
Member Author

Interesting! Looks like the browser automatically inserts a <tbody> element.

@rschristian
Copy link
Member

This doesn't throw/log an error, but it should; while the spec technically allows for <tr> to be a child of <table>, it does this knowing full well that all parsers will instead wrap it inside of a <tbody>.

We should warn here.

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

Successfully merging a pull request may close this issue.

5 participants