Abort XHR on popstate / Maintain history when aborting XHR #162

Merged
merged 1 commit into from Jan 12, 2013

Projects

None yet

3 participants

@reed
Collaborator
reed commented Jan 11, 2013

I was working on a fix for #155 yesterday, but @davydotcom beat me to the punch this morning. He took almost the exact approach as I was, but his commit didn't handle a couple side effects:

  1. If you clicked a link and then clicked the back button before the request finished, the page would still change to the requested page once the request finally finished. Adding xhr?.abort() to fetchHistory() fixes this.
  2. If you clicked a link and then clicked another link before the first one loaded, the first one will abort and the second requested page will load. This is what we just fixed, but if the next thing you do is click the back button, nothing will happen. Calling rememberCurrentUrl() on xhr abort ensures the proper behavior when navigating the history.
  3. I also refactored a little bit by moving all the xhr = null statements into the onloadend callback.
@davydotcom
Contributor

just checked over all of this, It all looks good, I like xhr?.abort() better as well 👍 @dhh

@davydotcom
Contributor

apologies for not catching those also, kinda rushed that one. Might tackle some better tests here soon.

@dhh dhh merged commit 4ed2285 into turbolinks:master Jan 12, 2013
@smidwap smidwap referenced this pull request Oct 7, 2013
Merged

Transition cache #286

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment