You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Server-side code is free to optimize its response by only returning HTML that matches the selector. For example, you might prefer to not render an expensive sidebar if the sidebar is not targeted.
I have large tables where I need to swap out table rows; each tr tag has an ID. The server response includes only the tr tag, so the entire response contents match the ID selector. However, unpoly can't find the ID in the response and updates the body instead of the table row.
If the server returns the entire table, then unpoly correctly updates the table. I also tried having the server return the tbody tag of the table, but unpoly couldn't extract the table row.
Then also tried assigning the ID to the tbody tag, and same result as tr - the content loads in the body tag.
The only way that I've encountered to get a tbody or tr tag swapped is to send the entire table from the server. That's still more efficient than the entire page, but it seems like a bug to me.
Have you tried rendering a minimal table with only that tr? Then using the id selector as you were.
I can't find a source to back this up right now, but I feel like there are certain tags that just can't exist on their own, and browser react indeterminately when they see them. My guess is tr, td, and a few others (tbody?) will just parse oddly without a parent table.
Like @adam12 said, wrap your <tr> in a <table> and it will work.
Unpoly uses your browser to parse the server response. The response always needs to be a valid HTML fragment, or the browser will consider it tag soup and silently rewrite your HTML:
Have you tried rendering a minimal table with only that tr? Then using the id selector as you were.
Yes, that's what I meant by "If the server returns the entire table, then unpoly correctly updates the table."
Unpoly uses your browser to parse the server response. The response always needs to be a valid HTML fragment.
Ok, thanks for the explanation. I don't know if there'd be a way to clarify the Optimizing responses section or not; something like:
Server-side code is free to optimize its response by only returning HTML that matches the selector. (The entire response body must be valid HTML as it is parsed by the browser. Tags that cannot exist on their own, such as tr should be wrapped in a table tag.)
I'm switching from IntercoolerJS where the response consisting only of tr tag worked fine. I was using ic-replace-target, which inserts the entire response - apparently with no browser parsing of the HTML.
Sorry for the bother on this ticket. Now that I understand the difference, it'll not be a problem to work with it.
Activity
adam12 commentedon Aug 6, 2019
Have you tried rendering a minimal
tablewith only thattr? Then using theidselector as you were.I can't find a source to back this up right now, but I feel like there are certain tags that just can't exist on their own, and browser react indeterminately when they see them. My guess is
tr,td, and a few others (tbody?) will just parse oddly without a parenttable.triskweline commentedon Aug 6, 2019
Like @adam12 said, wrap your
<tr>in a<table>and it will work.Unpoly uses your browser to parse the server response. The response always needs to be a valid HTML fragment, or the browser will consider it tag soup and silently rewrite your HTML:
thinkwelltwd commentedon Aug 6, 2019
Yes, that's what I meant by "If the server returns the entire table, then unpoly correctly updates the table."
Ok, thanks for the explanation. I don't know if there'd be a way to clarify the Optimizing responses section or not; something like:
I'm switching from IntercoolerJS where the response consisting only of
trtag worked fine. I was using ic-replace-target, which inserts the entire response - apparently with no browser parsing of the HTML.Sorry for the bother on this ticket. Now that I understand the difference, it'll not be a problem to work with it.
[fragment] Parse incomplete HTML fragments that only contain a <tr> o…
triskweline commentedon Sep 22, 2025
Unpoly 3.12.0-rc6 can process table rows without an enclosing
<table>.alexandremjacques commentedon Sep 22, 2025
Oh. That's interesting. Any preview documentation on how to do that?
triskweline commentedon Sep 22, 2025
There's no new API. You target any
<tr>element and the server can now respond with HTML that only contains an updated<tr>element.thinkwelltwd commentedon Sep 24, 2025
Many thanks, @triskweline! What a nice enhancement. 💯