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
{{ message }}
Repository navigation
up-hungry on a parent causes up.render() to fail to target #681
I have a parent div with up-hungry. When clicking a button, I call await up-render() with a target of the nested element. The resulting response object has an empty response.fragments array. In unpoly 3.3.0 and earlier, the response.fragments array was populated.
In the repro, you can change the script version. I expect both buttons to be replaced with the string replacement, while an alert demonstrates an empty fragment response. Note that the difference between child-1 and child-2 is up-hungry.
Steps to reproduce the behavior:
Go to reproduction project linked above
Click the child buttons
Success is no alerts
Expected behavior
Button should be replaced with the string replacement-1
Ah, nested resolution makes sense. When I first read this, I assumed this would also lead to what was send to the server in X-Target, but the server sees X-Target: child1. So, it thinks that just returning #child1 is valid. That seems inconsistent if the client is going to ignore #child1 in the response.
For more context, I ran across this with a relatively complex autocomplete widget that's sometimes present in a <header> and sometimes in a <footer>. The larger elements are up-hungry, but I don't want to explicitly target them while doing the autocomplete, because that's way more expensive than the autocomplete, and it messes with focus of the text box that triggers the autocomplete.
Some ideas (from the peanut gallery, I don't understand unpoly's internals).
Keep the original explicit targets around and use them from the response
Make the reconciliation a list of preferences, ie prefer to render #hungry, but if not found, then render #child1
Defer the nested reconciliation until after the server response arrives and include the response in the reconciliation (ie prune options that aren't in the response)
Re-run nested reconciliation if there are no matches from the server
Activity
triskweline commentedon Dec 2, 2024
Thanks for investigating @c33howard.
I believe the following happens:
#hungry, #child1, which Unpoly reconciles to just#hungry.#hungry. It did include#child1, but we already removed that from the render pass when consolidating earlier.I'm not sure how to improve the behavior. I know we need to keep the reconciliation mechanism.
c33howard commentedon Dec 2, 2024
Ah, nested resolution makes sense. When I first read this, I assumed this would also lead to what was send to the server in
X-Target, but the server seesX-Target: child1. So, it thinks that just returning#child1is valid. That seems inconsistent if the client is going to ignore#child1in the response.For more context, I ran across this with a relatively complex autocomplete widget that's sometimes present in a
<header>and sometimes in a<footer>. The larger elements areup-hungry, but I don't want to explicitly target them while doing the autocomplete, because that's way more expensive than the autocomplete, and it messes with focus of the text box that triggers the autocomplete.Some ideas (from the peanut gallery, I don't understand unpoly's internals).
#hungry, but if not found, then render#child1