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

<await> tag doesn't render correctly with client-reorder when inside <table> element #2242

Open
vwong opened this issue May 31, 2024 · 3 comments
Labels
type:unverified bug A bug report that has not been verified

Comments

@vwong
Copy link
Contributor

vwong commented May 31, 2024

Marko Version: 5.35.0

Details

I'm trying to run <await client-reorder> inside a <table> to await each row independently.

Expected Behavior

<table> is rendered correctly, the same way as without client-reorder.

Actual Behavior

Both placeholder and result remains in the HTML.

Steps to Reproduce

See reproduction

@vwong vwong added the type:unverified bug A bug report that has not been verified label May 31, 2024
@vwong
Copy link
Contributor Author

vwong commented May 31, 2024

Curiously, this works as expected in the Marko Playground

@DylanPiercey
Copy link
Contributor

DylanPiercey commented Jun 1, 2024

@vwong this is a somewhat known issue.

I'm not sure of a good way to work around it.
In essence the reason this is problematic is because when a browser parser a <table> it will insert elements (eg wrapping <tbody>, <tr>, <td> etc).

The way client-reorder works currently is by inserting a dummy element to wrap your <@placeholder> content, so that Marko can find and replace that content after. In your case this ends up with markup something like <span><tr><td> which the browser attempts to fix and Marko doesn't recover from (hydration issue).

I would recommend only putting the reordered <await>'s inside of the <td> or outside of the table altogether (sadly).

FYI the reason this works in the playground is because the playground lies to you. It actually does a client render (which does technically support async) and client renders don't go through the browsers html parser and avoids any kind of hydration issue.


I am very open to discussing ways we could potentially work around this although I'm not sure we can.
Possibly if we changed the placeholder to be wrapped with comments - but that makes the inlined out of order runtime more complicated and maybe isn't worth it. Also I'm not sure off the top of my head if the browser moves comments within tables while parsing like it moves other stuff.

@vwong
Copy link
Contributor Author

vwong commented Jun 1, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:unverified bug A bug report that has not been verified
Projects
None yet
Development

No branches or pull requests

2 participants