turbograft 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5a814c49eaff1fbe7cf0bb02f67ef8d96fe8ff9
4
- data.tar.gz: dd94aabbd02817b9ce92f99f87651daa94975176
3
+ metadata.gz: c51f5ed8a155f29814d99f83a20387c3397a29a9
4
+ data.tar.gz: 92a13dac1c2aadc0526a40c78f5d67097e3a833e
5
5
  SHA512:
6
- metadata.gz: 3cfa4e748a8278ab568aac8b985eaa46df40fbf6ca063785fd66be1408ad55221d146683d0edeeba1f047a1ede182dc45f000353639886d1ffc27df958320168
7
- data.tar.gz: 262fa76bf7948cd31f889e881c3b63d8a88a41d697a8d1fc37ac06d5db306905fa3508512791b0435b2e95eb18eda1662ec6f1d7b278c61d3ef2132723992c16
6
+ metadata.gz: 85f28b6d5b0851b2c7d6684418eeccb1baf690d1a71eddc1498f8ce99acea81c7864834f7b7861d6e55888a5b399ae59d19dcdd714b5edd29a5eb9c2122948f4
7
+ data.tar.gz: 0d8cd7e44378440bffc0883520c0d35408cd9e52262d6f3284324172db8b0a457b27dbb41a8534b0787103f479b0413664133004878a3a9be045c7a802dd19fb
@@ -26,8 +26,7 @@ updateScriptTags = (activeDocument, newScripts, callback) ->
26
26
  )
27
27
 
28
28
  extractTrackedAssets = (doc) ->
29
- for node in doc.head.children when node.dataset.turbolinksTrack?
30
- node
29
+ [].slice.call(doc.querySelectorAll('[data-turbolinks-track]'))
31
30
 
32
31
  filterForNodeType = (nodeType) ->
33
32
  (node) -> node.nodeName == nodeType
@@ -130,27 +130,33 @@ class window.Turbolinks
130
130
  @loadPage: (url, xhr, options = {}) ->
131
131
  triggerEvent 'page:receive'
132
132
  options.updatePushState ?= true
133
- if upstreamDocument = processResponse(xhr, options.partialReplace)
133
+ if upstreamDocument = processResponse(xhr)
134
134
  reflectNewUrl url if options.updatePushState
135
-
136
- new TurboHead(document, upstreamDocument).update(
137
- onHeadUpdateSuccess = ->
138
- nodes = changePage(
139
- upstreamDocument.querySelector('title')?.textContent,
140
- removeNoscriptTags(upstreamDocument.querySelector('body')),
141
- CSRFToken.get(upstreamDocument).token,
142
- 'runScripts',
143
- options
144
- )
145
- reflectRedirectedUrl(xhr) if options.updatePushState
146
- options.onLoadFunction?()
147
- triggerEvent 'page:load', nodes
148
- ,
149
- onHeadUpdateError = ->
150
- Turbolinks.fullPageNavigate(url.absolute)
151
- )
135
+ if options.partialReplace
136
+ updateBody(upstreamDocument, xhr, options)
137
+ else
138
+ new TurboHead(document, upstreamDocument).update(
139
+ onHeadUpdateSuccess = ->
140
+ updateBody(upstreamDocument, xhr, options)
141
+ ,
142
+ onHeadUpdateError = ->
143
+ Turbolinks.fullPageNavigate(url.absolute)
144
+ )
152
145
  else
153
- Turbolinks.fullPageNavigate(url.absolute)
146
+ triggerEvent 'page:error', xhr
147
+ Turbolinks.fullPageNavigate(url.absolute) if url?
148
+
149
+ updateBody = (upstreamDocument, xhr, options) ->
150
+ nodes = changePage(
151
+ upstreamDocument.querySelector('title')?.textContent,
152
+ removeNoscriptTags(upstreamDocument.querySelector('body')),
153
+ CSRFToken.get(upstreamDocument).token,
154
+ 'runScripts',
155
+ options
156
+ )
157
+ reflectRedirectedUrl(xhr) if options.updatePushState
158
+ options.onLoadFunction?()
159
+ triggerEvent 'page:load', nodes
154
160
 
155
161
  changePage = (title, body, csrfToken, runScripts, options = {}) ->
156
162
  document.title = title if title
@@ -322,7 +328,7 @@ class window.Turbolinks
322
328
  pageChangePrevented = (url) ->
323
329
  !triggerEvent('page:before-change', url)
324
330
 
325
- processResponse = (xhr, partial = false) ->
331
+ processResponse = (xhr) ->
326
332
  clientOrServerError = ->
327
333
  return false if xhr.status == 422 # we want to render form validations
328
334
  400 <= xhr.status < 600
@@ -1,3 +1,3 @@
1
1
  module TurboGraft
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbograft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Plettenberg-Dussault
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2016-08-24 00:00:00.000000000 Z
16
+ date: 2016-08-29 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: coffee-rails