Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #144 from reednj77/ie10-anchor-fix

Remove hash from XHR url - Fix #142
  • Loading branch information...
commit 26f8721fa4db95ffeb44e9706eeaa793336257f6 2 parents 797e9c8 + a4ac6af
@dhh dhh authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/assets/javascripts/turbolinks.js.coffee
View
14 lib/assets/javascripts/turbolinks.js.coffee
@@ -17,8 +17,11 @@ visit = (url) ->
fetchReplacement = (url) ->
triggerEvent 'page:fetch'
+ # Remove hash from url to ensure IE 10 compatibility
+ safeUrl = removeHash url
+
xhr = new XMLHttpRequest
- xhr.open 'GET', url, true
+ xhr.open 'GET', safeUrl, true
xhr.setRequestHeader 'Accept', 'text/html, application/xhtml+xml, application/xml'
xhr.setRequestHeader 'X-XHR-Referer', referer
@@ -112,6 +115,13 @@ recallScrollPosition = (page) ->
resetScrollPosition = ->
window.scrollTo 0, 0
+removeHash = (url) ->
+ link = url
+ unless url.href?
+ link = document.createElement 'A'
+ link.href = url
+ link.href.replace link.hash, ''
+
triggerEvent = (name) ->
event = document.createEvent 'Events'
@@ -177,7 +187,7 @@ crossOriginLink = (link) ->
location.protocol isnt link.protocol or location.host isnt link.host
anchoredLink = (link) ->
- ((link.hash and link.href.replace(link.hash, '')) is location.href.replace(location.hash, '')) or
+ ((link.hash and removeHash(link)) is removeHash(location)) or
(link.href is location.href + '#')
nonHtmlLink = (link) ->
Please sign in to comment.
Something went wrong with that request. Please try again.