turbolinks 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -52,7 +52,7 @@ Asset change detection
52
52
 
53
53
  You can track certain assets, like application.js and application.css, that you want to ensure are always of the latest version inside a Turbolinks session. This is done by marking those asset links with data-turbolinks-track, like so:
54
54
 
55
- <link href="/assets/application.css?9bd64a86adb3cd9ab3b16e9dca67a33a.css" media="screen" rel="stylesheet" type="text/css" data-turbolinks-track>
55
+ ```<link href="/assets/application-9bd64a86adb3cd9ab3b16e9dca67a33a.css" rel="stylesheet" type="text/css" data-turbolinks-track>```
56
56
 
57
57
  If those assets change URLs (embed an md5 stamp to ensure this), the page will do a full reload instead of going through Turbolinks. This ensures that all Turbolinks sessions will always be running off your latest JavaScript and CSS.
58
58
 
@@ -1,7 +1,7 @@
1
1
  initialized = false
2
2
  currentState = null
3
3
  referer = document.location.href
4
- trackingAssets = []
4
+ loadedAssets = null
5
5
  pageCache = {}
6
6
  createDocument = null
7
7
 
@@ -99,9 +99,6 @@ rememberCurrentUrl = ->
99
99
  rememberCurrentState = ->
100
100
  currentState = window.history.state
101
101
 
102
- rememberCurrentTrackingAssets = ->
103
- trackingAssets = extractTrackAssets document
104
-
105
102
  rememberInitialPage = ->
106
103
  unless initialized
107
104
  rememberCurrentUrl()
@@ -121,13 +118,14 @@ triggerEvent = (name) ->
121
118
  event.initEvent name, true, true
122
119
  document.dispatchEvent event
123
120
 
121
+
124
122
  extractTrackAssets = (doc) ->
125
123
  (node.src || node.href) for node in doc.head.childNodes when node.getAttribute?('data-turbolinks-track')?
126
124
 
127
-
128
- assetsChanged = (doc)->
129
- extractedTrackAssets = extractTrackAssets doc
130
- extractedTrackAssets.length isnt trackingAssets.length or intersection(extractedTrackAssets, trackingAssets).length != trackingAssets.length
125
+ assetsChanged = (doc) ->
126
+ loadedAssets ||= extractTrackAssets document
127
+ fetchedAssets = extractTrackAssets doc
128
+ fetchedAssets.length isnt loadedAssets.length or intersection(fetchedAssets, loadedAssets).length isnt loadedAssets.length
131
129
 
132
130
  intersection = (a, b) ->
133
131
  [a, b] = [b, a] if a.length > b.length
@@ -205,7 +203,6 @@ browserSupportsPushState =
205
203
  window.history and window.history.pushState and window.history.replaceState and window.history.state != undefined
206
204
 
207
205
  if browserSupportsPushState
208
- rememberCurrentTrackingAssets()
209
206
  document.addEventListener 'click', installClickHandlerLast, true
210
207
 
211
208
  window.addEventListener 'popstate', (event) ->
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: turbolinks
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.0
5
+ version: 0.6.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Heinemeier Hansson