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
When the response to a submit from within a Turbo Frame is a redirect, the content of the new Turbo Frame is retrieved by setting the src attribute of the Turbo Frame to the redirect URL (that seems to happen here: https://github.com/hotwired/turbo/blob/main/src/core/session.js#L102 ). Once the content has been loaded, however, the src attribute is not removed but remains on the new <turbo-frame> element.
Expected Behavior
I expected that the src attribute would be removed from the Turbo Frame once the content from the redirect has been loaded, since the new Turbo Frame does not have a src attribute.
Background
This is causing issues for me when using a different JavaScript library with no knowledge of Turbo (this one: https://github.com/innoq/tabelle) because the other library removes the Turbo Frame node from the DOM and then reinserts it. Because the src attribute isn't removed after the content of the Frame is loaded, once the Turbo Frame is reinserted in the DOM, Turbo (understandably) thinks that the src attribute needs to be retrieved from the Server and does so. This results in an infinite loop where (1) Turbo retrieves a resource from the server and replaces the content of the Frame, (2) the JavaScript library shuffles the DOM and removes and reinserts the Turbo Frame into the DOM, then (3) go back to (1)
It took me a while to track down this issue because I wasn't manually setting any src attributes on my Turbo Frames, so I couldn't figure out where the src attribute in the DOM of the <turbo-frame> was coming from.
The text was updated successfully, but these errors were encountered:
joyheron
changed the title
src attribute is not removed from turbo-frame after loading contentsrc attribute is not removed from turbo-frame after loading content
Sep 10, 2024
Actual Behavior
When the response to a submit from within a Turbo Frame is a redirect, the content of the new Turbo Frame is retrieved by setting the
src
attribute of the Turbo Frame to the redirect URL (that seems to happen here: https://github.com/hotwired/turbo/blob/main/src/core/session.js#L102 ). Once the content has been loaded, however, thesrc
attribute is not removed but remains on the new<turbo-frame>
element.Expected Behavior
I expected that the
src
attribute would be removed from the Turbo Frame once the content from the redirect has been loaded, since the new Turbo Frame does not have asrc
attribute.Background
This is causing issues for me when using a different JavaScript library with no knowledge of Turbo (this one: https://github.com/innoq/tabelle) because the other library removes the Turbo Frame node from the DOM and then reinserts it. Because the
src
attribute isn't removed after the content of the Frame is loaded, once the Turbo Frame is reinserted in the DOM, Turbo (understandably) thinks that thesrc
attribute needs to be retrieved from the Server and does so. This results in an infinite loop where (1) Turbo retrieves a resource from the server and replaces the content of the Frame, (2) the JavaScript library shuffles the DOM and removes and reinserts the Turbo Frame into the DOM, then (3) go back to (1)It took me a while to track down this issue because I wasn't manually setting any
src
attributes on my Turbo Frames, so I couldn't figure out where thesrc
attribute in the DOM of the<turbo-frame>
was coming from.The text was updated successfully, but these errors were encountered: