-
Notifications
You must be signed in to change notification settings - Fork 475
Create Frame Snapshot from Fetch Response HTML #887
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Page With Preloading Frame</title> | ||
| <script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <turbo-frame id="menu" src="/src/tests/fixtures/frames/preloading.html"></turbo-frame> | ||
| </body> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Frame Preloading</title> | ||
| <script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
| <script src="/src/tests/fixtures/test.js"></script> | ||
| </head> | ||
| <body> | ||
| <turbo-frame id="menu" src="/src/tests/fixtures/frames/preloading.html"></turbo-frame> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,14 @@ | ||
| <turbo-frame id="eager-loaded-frame" > | ||
| <h2>Eager-loaded frame: Loaded</h2> | ||
| </turbo-frame> | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Frames: Frame for Eager</title> | ||
| <script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
| <script src="/src/tests/fixtures/test.js"></script> | ||
| </head> | ||
| <body> | ||
| <turbo-frame id="eager-loaded-frame" > | ||
| <h2>Eager-loaded frame: Loaded</h2> | ||
| </turbo-frame> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,14 @@ | ||
| <turbo-frame id="part"> | ||
| <h2>Frames: #frame-part</h2> | ||
| </turbo-frame> | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Frames: Part</title> | ||
| <script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
| <script src="/src/tests/fixtures/test.js"></script> | ||
| </head> | ||
| <body> | ||
| <turbo-frame id="part"> | ||
| <h2>Frames: #frame-part</h2> | ||
| </turbo-frame> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,15 @@ | ||
| <turbo-frame id="menu"> | ||
| <a href="/src/tests/fixtures/preloaded.html" id="frame_preload_anchor" data-turbo-preload="true">Visit preloaded | ||
| page</a> | ||
| </turbo-frame> | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Frames: Preloading</title> | ||
| <script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
| <script src="/src/tests/fixtures/test.js"></script> | ||
| </head> | ||
| <body> | ||
| <turbo-frame id="menu"> | ||
| <a href="/src/tests/fixtures/preloaded.html" id="frame_preload_anchor" data-turbo-preload="true">Visit preloaded | ||
| page</a> | ||
| </turbo-frame> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,20 @@ | ||
| <turbo-frame id="tab-frame" data-turbo-action="advance"> | ||
| <div> | ||
| <a id="tabs-1" href="/src/tests/fixtures/tabs.html">Tab 1</a> | ||
| <a id="tabs-2" href="/src/tests/fixtures/tabs/two.html">Tab 2</a> | ||
| <a id="tabs-3" href="/src/tests/fixtures/tabs/three.html">Tab 3</a> | ||
| </div> | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Frame</title> | ||
| <script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
| <script src="/src/tests/fixtures/test.js"></script> | ||
| </head> | ||
| <body> | ||
| <turbo-frame id="tab-frame" data-turbo-action="advance"> | ||
| <div> | ||
| <a id="tab-1" href="/src/tests/fixtures/tabs.html">Tab 1</a> | ||
| <a id="tab-2" href="/src/tests/fixtures/tabs/two.html">Tab 2</a> | ||
| <a id="tab-3" href="/src/tests/fixtures/tabs/three.html">Tab 3</a> | ||
| </div> | ||
|
|
||
| <div id="tab-content">Three</div> | ||
| </turbo-frame> | ||
| <div id="tab-content">Three</div> | ||
| </turbo-frame> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,20 @@ | ||
| <turbo-frame id="tab-frame" data-turbo-action="advance"> | ||
| <div> | ||
| <a id="tab-1" href="/src/tests/fixtures/tabs.html">Tab 1</a> | ||
| <a id="tab-2" href="/src/tests/fixtures/tabs/two.html">Tab 2</a> | ||
| <a id="tab-3" href="/src/tests/fixtures/tabs/three.html">Tab 3</a> | ||
| </div> | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Frame</title> | ||
| <script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
| <script src="/src/tests/fixtures/test.js"></script> | ||
| </head> | ||
| <body> | ||
| <turbo-frame id="tab-frame" data-turbo-action="advance"> | ||
| <div> | ||
| <a id="tab-1" href="/src/tests/fixtures/tabs.html">Tab 1</a> | ||
| <a id="tab-2" href="/src/tests/fixtures/tabs/two.html">Tab 2</a> | ||
| <a id="tab-3" href="/src/tests/fixtures/tabs/three.html">Tab 3</a> | ||
| </div> | ||
|
|
||
| <div id="tab-content">Two</div> | ||
| </turbo-frame> | ||
| <div id="tab-content">Two</div> | ||
| </turbo-frame> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely cause a full page reload because the
responseHTMLwill only have a minimal<head>and therefore the tracked elements won't be identical.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching this @domchristie. I'm not sure how to best resolve the issue mentioned in #1047. Do you have an idea on what to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanpdoyle Can this line be reverted or will that break the intention of #867 / hotwired/turbo-rails#428?
Otherwise, I'm beginning to feel that the different visit usages warrant a different modelling.
This would be a fairly big refactor, but might be worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#430 explores a
FrameVisit, but I'm unsure of what changes would be necessary to incorporate a fix for this issue.I'm unsure of the implications of reverting it. Is there a conditional that could be introduced to support responses without a
<head>and responses from newerturbo-railsversions that send a minimal head?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like v7.3.0 includes #867 so reverting should work (although I'm not sure how!?)
Off the top of my head (pun intended ;), I'm not sure how
HeadSnapshotcould distinguish between a "minimal layout" head from a frame visit and standard visit, where the page's tracked assets have actually changedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't feel right to me that we call
session.proposeVisitIfNavigatedWithActionafter rendering a frame response. (In the same way it doesn't feel right to propose a second visit after rendering a redirected response.) In these cases, we're not "visiting" a new location, we're just using the side-effects of the visit lifecycle.In terms of what I had in mind for implementing different visit types: I was thinking that each Visit type could share an interface, and each implementation could respond accordingly (e.g. a
RedirectVisitwouldn't dispatch any events because the Visit lifecycle events have already been broadcast by the initial Visit.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any progress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change broke Restoration Visits with
turbo-frame data-turbo-action="advance".see:
Is this something we can revert or is there a different approach we can take?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also see #1300
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tleish thanks for all the referenced links.
I'm also experiencing this problem where page cache gets messed up when combining turbo frames with turbo action "advance" and navigating back after having navigated forward in the frame.
This is, I think, a pretty common usage pattern for turbo frames. I've seen it promoted on many blog posts and youtube videos like this one) so it calls my attention this hasn't been addressed yet.
The best workaround I've found (lost track of the source by now) is to use a custom
app/views/layouts/turbo_rails/frame.html.erbfile that includes the whole sameheadsection from theapp/views/layouts/application.html.erbtemplate overriding the trimmed-down version of theturbo-railsgem. But I'm not sure that solves all edge cases.