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

src attribute is not removed from turbo-frame after loading content #1307

Open
joyheron opened this issue Sep 10, 2024 · 0 comments
Open

src attribute is not removed from turbo-frame after loading content #1307

joyheron opened this issue Sep 10, 2024 · 0 comments

Comments

@joyheron
Copy link

joyheron commented 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, 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.

@joyheron joyheron changed the title src attribute is not removed from turbo-frame after loading content src attribute is not removed from turbo-frame after loading content Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant