feat: export PageSnapshot to allow for caching HTML strings #301
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.
Why?
Currently im working on Mrujs, a modern ujs drop-in replacement thats fully client-side and has a built-in navigation adapter which leverages Turbo / Turbolinks. I have a working setup to prevent double navigation on successful form submissions that redirect with Turbolinks, however, I cant do the same with Turbo. This is because the code used to cache PageSnapshots is not exported. With the exported class, I can take advantage of caching a response body from a fetch request and then manually storing it in the cache and then trigger a "restore" visit through Turbo[links] so that it doesnt trigger double navigation and wipe away any flashes.
https://github.com/ParamagicDev/mrujs/blob/b21c2475dc56c635f3cd05c34bf2f1b971c97f3b/src/navigationAdapter.ts#L155-L157
^ Those are the lines of code dependent on the PageSnapshot class.