-
Turbolinks supports
append
andprepend
options.# Specifying the `append` or `prepend` option to `Turbolinks.replace` and `Turbolinks.visit` causes the children of the matching nodes in the new document to be appended/prepended to the corresponding node in the existing document. Turbolinks.visit(url, prepend: ['change']) Turbolinks.replace(html, append: ['change'])
# In Ruby, the target nodes' ids are passed via `append` or `prepend`. render render_options, append: 'comment-list' redirect_to path, prepend: 'comment-list'
Alec Larsen
-
Turbolinks.visit
andTurbolinks.replace
accept atitle
option.Guillaume Malette
# Specifying a title will overwrite the title Turbolinks.visit(url, title: 'New title') # Using `false` as a title will prevent Turbolinks from changing the title Turbolinks.replace(html, title: false)
-
Noscript tags are no longer removed from body on page changes.
René Hansen
-
Deprecated
redirect_via_turbolinks_to
in favor ofredirect_to url, turbolinks: true
.Thibaut Courouble
-
Make
redirect_to
perform aTurbolinks.visit
by default when the request isXHR
and notGET
, unlessturbolinks: false
is passed toredirect_to
.David Heinemeier Hansson, Thibaut Courouble
-
Add partial replacement functionality.
New
Turbolinks.replace
API:# Replace <body> Turbolinks.replace(html) # Replace nodes with id "comments", "comments:foo", etc. Turbolinks.replace(html, change: ['comments']) # Replace <body>, except node with id "flash" Turbolinks.replace(html, keep: ['flash']) # Replace <body>, including [data-turbolinks-permanent] nodes Turbolinks.replace(html, flush: true)
Nodes with
[data-turbolinks-permanent]
are never replaced, unlessflush: true
is passed.Nodes with
[data-turbolinks-temporary]
are always replaced, unlesskeep: [id]
is passed.The same options are available on
Turbolinks.visit
.New
redirect_to
API:# Force a Turbolinks.visit response redirect_to url_for_option, turbolinks: true # Force a normal redirection redirect_to url_for_option, turbolinks: false # Pass options to Turbolinks.visit redirect_to url_for_option, change: :comments redirect_to url_for_option, change: [:comments, :sidebar] redirect_to url_for_option, keep: :sidebar redirect_to url_for_option, keep: [:sidebar, :flash] redirect_to url_for_option, flush: true
New
render
API:# Make the response perform a Turbolinks.replace when the request is XHR and not GET, # and pass options Turbolinks.replace render render_options, change: :comment_form render render_options, keep: :flash render render_options, flush: true # Force a normal render (ignore :change, :keep and :flush options) render render_options, change: :comment_form, turbolinks: false # Force a Turbolinks.replace response render render_options, change: :comment_form, turbolinks: true
Kristian Plettenberg-Dussault, Thibaut Courouble, David Heinemeier Hansson
-
Trigger
page:partial-load
insteadpage:load
on partial replacement (Turbolinks.visit()
orTurbolinks.replace()
withchange
option)Thibaut Courouble
-
Add a
page:after-remove
event, triggered after an element (stored inevent.data
) is removed from the DOM (partial replacement), or a body element is evicted from the cache, to give user scripts the opportunity to clean up references to these elements and avoid memory leaks.This event replaces the
page:expire
event for cleaning up cached pages.Thibaut Courouble, Drew Martin
-
Clean up jQuery event handlers automatically when the
page:after-remove
event is fired (fix memory leak).Thibaut Courouble, Drew Martin
-
Fix
URI::InvalidURIError
whenX-XHR-Referer
is invalid and the request performs a redirection.Thibaut Courouble
-
Fix missing
X-XHR-Redirected-To
header following routes.rb redirect.Thibaut Courouble
-
Add ability to control XHR request caching by adding cache-busting param to the URL.
# Disable caching globally Turbolinks.disableRequestCaching() # Disable caching per request Turbolinks.visit url, cacheRequest: false
Nick Reed
-
Enable progress bar feature by default. Remove
Turbolinks.enableProgressBar()
from public API, replaced with:Turbolinks.ProgressBar.enable() Turbolinks.ProgressBar.disable()
Nick Reed
-
Add basic control of progress bar to public API.
Turbolinks.ProgressBar.start() Turbolinks.ProgressBar.advanceTo(value) Turbolinks.ProgressBar.done()
Nick Reed
-
Add ability to re-run scripts on back/forward navigation by specifying
data-turbolinks-eval=always
on the<script>
tag.Thibaut Courouble, Kevin Hughes
-
Add ability to opt out of Turbolinks in certain controllers by setting
config.turbolinks.auto_include
tofalse
inapplication.rb
and includingTurbolinks::Controller
in the controllers where Turbolinks is used.Thibaut Courouble, Elia Schito
-
Add ability to prevent
Turbolinks.visit
from resetting the scroll position.Turbolinks.visit url, scroll: false
-
Attach affected elements to the
page:before-unload
,page:change
,page:load
andpage:partial-load
events (inevent.data
).Thibaut Courouble
-
Force a normal redirection when calling
Turbolinks.visit
with a different-origin URL.Thibaut Courouble
-
Trigger the
page:before-change
event on manual call toTurbolinks.visit()
.Thibaut Courouble
-
Prevent the progress bar from filling the entire screen in older versions of Safari.
Adam Becker, Javan Makhmali
-
Use document.documentElement.cloneNode() when parsing new documents to properly handle device pixel ratio calculations.
Tom Ward
-
Reflect the redirected url before actually changing the page, so page-change listeners get to see the final URL, rather than the before-redirect URL.
DHH
-
Add an optional progress bar indicator while loading. See README for example and details. This will be on by default from Turbolinks 3.0.
Javan Makhmali
-
Avoid double requests when the server returns a cross origin redirect by directly loading the redirect location.
Hsiaoming Yang
-
Expose event list via
Turbolinks.EVENTS
.Robert Mosolgo, William Meleyal
-
Add a
page:before-unload
event, triggered immediately before the page is changed. The event is triggered regardless of where the page came from (server vs cache).Note that this event is not canceleable like the similarly named native event
beforeunload
, and therefore should not be viewed as counterparts.Nick Reed
-
If the Prototype library is loaded, additionally trigger events with
Event.fire
so they can be observed using Prototype methods like.on()
and.observe()
.Nick Reed
-
Maintain correct load order of scripts in the
body
by explicitly settingasync
to false if it is not already set.Nick Reed
-
Include the target URL in the event data for the
page:before-change
event.Nick Reed
-
Fix issue where clicking a link with
href="#"
would not be ignored by Turbolinks when the current location already ends in an empty anchor.Nick Reed
-
Handle HTML parsing inconsistencies present in Safari 7.1+.
Nick Reed
-
Only set the request_method cookie after non-GET requests.
Matt Brictson
-
Revert pushState timing behavior to how it was prior to v2.2.0. The URL will not change until the request returns from the server and the response is determined to be valid. This notably fixes the behavior of the back button after a Rails error page is loaded.
Note that any functions bound to
page:fetch
orpage:before-change
can no longer depend ondocument.location
to determine the URL of the new page. Instead, use the data bound to the event object (e.originalEvent.data.url
).Nick Reed
-
Fix HTML5 autofocus for Firefox.
Nick Reed
-
Prevent
url_for
errors when using unsupported Ruby 1.8. Note thatlink_to :back
andredirect_to :back
will not function properly when using Turbolinks with Ruby 1.8.Nick Reed
-
Fix handling of anchors/hashes with respect to navigating the browser history.
Nick Reed
-
Add support for Rails 4.2.
Aaron Patterson
-
Always use absolute URLs as cache keys and in state objects. Eliminates possibility of multiple cache objects for the same page.
Nick Reed
-
Allow periods in a link's query string (ex.
/users?sort=account.email
) without it interfering with the extension check.Kuba Kuźma
-
Don't process links with no
href
attribute.Nick Reed
-
Do not store redirect_to location in session if the request did not come from Turbolinks. Fixes rare bug that manifests when directing items like image tag sources through ActionController and subsequently redirecting those requests to a different origin. This would cause the session variable to be set but never deleted (since the redirect request was external), resulting in the next request being declared a redirect no matter what.
Nick Reed
-
Extend handling of Firefox history.state bug through Firefox 27.
Nick Reed
-
Fix handling of
:back
option in ActionView helpersurl_for
andlink_to
.Nick Reed
-
Delay binding of history change handler long enough to bypass the popstate event that some browsers fire on the initial page load. Prevents duplicate requests in certain scenarios when traversing the browser history.
Anton Pawlik + Nick Reed
-
Add transition cache feature. When enabled, cached copies of pages will be shown before fetching and displaying a new copy from the server. A individual page can be opted-out by adding
data-no-transition-cache
to any DOM element on the page.Matt De Leon
-
Improve browser support for
noscript
tag removal.Nick Reed
-
Add a
page:expire
event for garbage collecting purposes. Triggered when a page is deleted from the cache due to reaching the cache size limit. Pass the cached page object in with the event data.Nick Reed
-
Allow configuration for additional link extensions to be processed by Turbolinks beyond
.html
.Turbolinks.allowLinkExtensions() # => ['html'] Turbolinks.allowLinkExtensions 'md' # => ['html', 'md'] Turbolinks.allowLinkExtensions 'coffee', 'scss' # => ['html', 'md', 'coffee', 'scss']
Nick Reed
-
Handle bug in Firefox 26 where the initial value of history.state is undefined instead of null, which led to Turbolinks not being initialized.
Nick Reed
-
Trigger page:update on page:change as well as jQuery's ajaxSuccess, if jQuery is available. This allows you to bind listeners to both full page changes and partial ajax updates. If you're not using jQuery, you can trigger page:update yourself on XMLHttpRequest to achieve the same result.
DHH
-
Trigger page:change on DOMContentLoaded so you can bind initializers that need to be run either on initial or subsequent page loads. This might be backwards incompatible, so we are also bumping the major version.
DHH
-
Expire
request_method
cookie after reading it.Nick Reed
-
Trigger events on DOMContentLoaded and jQuery's ajaxSuccess regardless of whether Turbolinks is initialized or not.
Nick Reed
-
Accommodate for bug in Chrome 31+ that causes
assetsChanged
to always return true. (#278)Andrew Volozhanin + Nick Reed
-
Change URL after fetching page.
Marek Labos
-
Fix compatibility with
link_to :back
.Marek Labos
-
Send correct referer after asset change detected.
Marek Labos
-
Add the
page:before-change
event, triggered when a Turbolinks-enabled link is clicked. Can be used to cancel the Turbolinks process.Nick Reed
-
Add Turbolinks.pagesCached() to the public API for getting and setting the size of the page cache.
Nick Reed
-
Handle 5xx responses
Marek Labos
-
Add the ability to not execute scripts on turbolinks page loads by specifying
data-turbolinks-eval=false
on the<script>
tag. For example:<script type="text/javascript" data-turbolinks-eval=false>
Mario Visic
-
Workaround for WebKit history state bug with regards to the handling of 4xx responses.
Yasuharu Ozaki
-
Extracted
fetchReplacement()
onload response-handling logic out intovalidateResponse()
.Nick Reed
-
Changed response header name from
X-XHR-Current-Location
toX-XHR-Redirected-To
. The header will only be sent if there has been a redirect. Fixes compatibility issue when usingredirect_to
with options such as anchors or a trailing slash by storing the redirect location in a session variable and then using that value to set the response header.Yasuharu Ozaki
-
Escape URLs when checking for cross-origin redirects.
Nick Reed
-
Improve performance of
constrainPageCacheTo
,executeScriptTags
, andremoveNoscriptTags
by not gathering and returning the results of the loop comprehensions.Tim Ruffles
-
Change page without Turbolinks when Turbolinks.visit is called in Chrome on iOS
Frank Showalter
-
Maintain the latest CSRF authenticity token in the
<meta name="csrf-token">
head tag, if it exists.Nick Reed
-
Added Turbolinks::XDomainBlocker module with after_filter to detect cross-domain redirects, returning 403 Forbidden so that the client will reissue the request without Turbolinks. (XSS Protection)
Mala
-
Remove hash when checking for non-HTML links. (XSS Protection)
Nick Reed + Mala
-
Check Content-Type response header. Fall back to non-Turbolinks request unless the header is either
text/html
,application/xhtml+xml
, orapplication/xml
. (XSS Protection)Nick Reed + Mala
-
Add a
page:receive
event, triggered the moment the ajax request returns, before any processing is done.Ben Weintraub
-
Explicitly set
useCapture
flag to default (false) on addEventListener and removeEventListener calls. Removes errors on older browsers where the flag was required.Matthieu Aussaguel
-
Copy
<noscript>
tag list by slicing so thatremoveNoscriptTags
works with multiple<noscript>
tags.Lion Vollnhals*
-
Copy
<script>
tag list by slicing so thatexecuteScriptTags
works in situations where a script removes itself from the DOM.Nick Reed
-
Add link to Turbolinks Compatibility project to README.
Nick Reed
-
Reflect X-XHR-Referer in
request.referer
Nick Reed
-
Add
createDocumentUsingDOM
method to avoid DOMParser exceptions on certain browsers.Nick Reed
-
Add jquery.turbolinks note to README
Ry Walker
-
Abort XHR on popstate / Maintain history when aborting XHR
Nick Reed
-
Disable Turbolinks on Chrome for iOS
David Estes
-
Disable Turbolinks after non-GET requests. Adds a cookie named
request_method
.Nick Reed
-
Abort XHR request if the user clicks another link before it finishes.
David Estes
-
Fall back to using
document.location.href = url
when there is an error so the applicationCache can be used in offline mode.R. Potter
-
Remove hash from XHR url to fix IE 10 bug.
Nick Reed
-
Scroll to anchor link id if link has an anchor tag.
Yasuharu Ozaki
-
Allow Turbolinks to function in non-Rails environments.
Yasuharu Ozaki
-
Optimize script tag execution by using script injection instead of
window.eval
. Deprecates the use of thedata-turbolinks-evaluated
attribute.Nick Reed + John-David Dalton
-
Delay existing asset check until it's time to compare them to the fetched page's assets.
Nick Reed
-
Only track assets that have a
data-turbolinks-track
attribute.Yasuharu Ozaki
-
Fix issue where anchors are being dropped from the URL when changing pages
Nick Reed
-
Update
extractLink
to safeguard against links that are removed from the DOM when clicked.Gleb Mazovetskiy
-
Improve
executeScriptTags
by handling case wheresrc
attribute is empty and usingwindow.eval
instead ofeval
.itzki
-
Add compatibility section to README
DHH
-
Add support for executing external script tags in the body
Nick Reed
-
Add note to README about dynamically added scripts
Manuel Meurer
-
Prevent issue with ActionController::Live by moving
set_xhr_current_location
from an an after_filter to a before_filter.Kentaro Kuribayashi
-
Only execute script tags on XHR request load, not from history fetch.
David Estes
-
Use
document.location.reload()
instead ofdocument.location.href = url
if the assets have changed.Yasuharu Ozaki
-
Remove the
samePageLink
method.Yasuharu Ozaki
-
Change the
pageCache
from an array to a hash to fix back button handling when window.history.length is > 0 on page load.Steven Bristol
-
Handle case where a node, after being clicked, is removed from the DOM before
extractLink
can climb it's tree.Steven Bristol
-
Ignore links with a
target
attribute.Steven Bristol
-
Use timestamp to initialize history state position.
Yasuharo Ozaki
-
Detect additional asset changes.
David Estes
-
Add
coffee-rails
as a dependency.Rafael Mendonça França
-
Remember assets as soon as possible to prevent dynamic scripts from being checked and added.
David Estes
-
Remove
cloneNode
since there is no need to reset the node's events.David Estes
-
Improve
createDocument
to only determine correct parser once.David Estes
-
Only execute script tags that contain Javascript.
Nick Reed
-
Issue a full page load if the assets change.
DHH
-
Detect asset changes.
David Estes