turbolinks 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3304eb3d931c741a7442be5b9519970f2aa78d6d
4
- data.tar.gz: 0ad12be429358638120b34e579a90fd3079b7c3a
3
+ metadata.gz: 9b00e79da70fa234720d97cb476bd21e237261fb
4
+ data.tar.gz: 84e4fbdd8d4949206833fc226a74609d511ee4ae
5
5
  SHA512:
6
- metadata.gz: 42f449c521d249d1fe1e5db70a1d7137de1f503522e13ce377346edcf476c14b4047c400dbd3f9171d54faa21c20d2cd1cb39a9003929a9f6433c128e72b0813
7
- data.tar.gz: eccafa4c18559af0d80f6db6d040a95be88d2f94eef3f0953bf392d1b801f075afde6f4ee0d5860db36eca29c442626945286449b6a1d275a4f35e8f200bee43
6
+ metadata.gz: 891313ccf4e64d39db45b2a92a2f4c5e95a93f55aeedb33c085501c2a631d4e1142eca5dcdf8bb463c363224280f5e4b10a64be3e2fb0cc84a7ad360a179ac37
7
+ data.tar.gz: 2a10327848e32dad567b76c1a4c653c979a5018805a56a1ed3f3d1f6e0913aeb8f25e56f1984b72fe2d892c2ca1c9b24b262c8c6e5f567aacbf4d529bb509481
@@ -8,7 +8,6 @@ loadedAssets = null
8
8
 
9
9
  referer = null
10
10
 
11
- createDocument = null
12
11
  xhr = null
13
12
 
14
13
  EVENTS =
@@ -43,6 +42,7 @@ enableTransitionCache = (enable = true) ->
43
42
  transitionCacheEnabled = enable
44
43
 
45
44
  enableProgressBar = (enable = true) ->
45
+ return unless browserSupportsTurbolinks
46
46
  if enable
47
47
  progressBar ?= new ProgressBar 'html'
48
48
  else
@@ -161,7 +161,7 @@ reflectRedirectedUrl = ->
161
161
  if location = xhr.getResponseHeader 'X-XHR-Redirected-To'
162
162
  location = new ComponentUrl location
163
163
  preservedHash = if location.hasNoHash() then document.location.hash else ''
164
- window.history.replaceState currentState, '', location.href + preservedHash
164
+ window.history.replaceState window.history.state, '', location.href + preservedHash
165
165
 
166
166
  crossOriginRedirect = ->
167
167
  redirect if (redirect = xhr.getResponseHeader('Location'))? and (new ComponentUrl(redirect)).crossOrigin()
@@ -260,68 +260,12 @@ CSRFToken =
260
260
  if current.token? and latest? and current.token isnt latest
261
261
  current.node.setAttribute 'content', latest
262
262
 
263
- browserCompatibleDocumentParser = ->
264
- createDocumentUsingParser = (html) ->
265
- (new DOMParser).parseFromString html, 'text/html'
266
-
267
- createDocumentUsingDOM = (html) ->
268
- doc = document.implementation.createHTMLDocument ''
269
- doc.documentElement.innerHTML = html
270
- doc
271
-
272
- createDocumentUsingWrite = (html) ->
273
- doc = document.implementation.createHTMLDocument ''
274
- doc.open 'replace'
275
- doc.write html
276
- doc.close()
277
- doc
278
-
279
- createDocumentUsingFragment = (html) ->
280
- head = html.match(/<head[^>]*>([\s\S.]*)<\/head>/i)?[0] or '<head></head>'
281
- body = html.match(/<body[^>]*>([\s\S.]*)<\/body>/i)?[0] or '<body></body>'
282
- htmlWrapper = document.createElement 'html'
283
- htmlWrapper.innerHTML = head + body
284
- doc = document.createDocumentFragment()
285
- doc.appendChild htmlWrapper
286
- doc
287
-
288
- # Use createDocumentUsingParser if DOMParser is defined and natively
289
- # supports 'text/html' parsing (Firefox 12+, IE 10)
290
- #
291
- # Use createDocumentUsingDOM if createDocumentUsingParser throws an exception
292
- # due to unsupported type 'text/html' (Firefox < 12, Opera)
293
- #
294
- # Use createDocumentUsingWrite if:
295
- # - DOMParser isn't defined
296
- # - createDocumentUsingParser returns null due to unsupported type 'text/html' (Chrome, Safari)
297
- # - createDocumentUsingDOM doesn't create a valid HTML document (safeguarding against potential edge cases)
298
- #
299
- # Use createDocumentUsingFragment if the previously selected parser does not
300
- # correctly parse <form> tags. (Safari 7.1+ - see github.com/rails/turbolinks/issues/408)
301
- buildTestsUsing = (createMethod) ->
302
- buildTest = (fallback, passes) ->
303
- passes: passes()
304
- fallback: fallback
305
-
306
- structureTest = buildTest createDocumentUsingWrite, =>
307
- (createMethod '<html><body><p>test')?.body?.childNodes.length is 1
308
-
309
- formNestingTest = buildTest createDocumentUsingFragment, =>
310
- (createMethod '<html><body><form></form><div></div></body></html>')?.body?.childNodes.length is 2
311
-
312
- [structureTest, formNestingTest]
313
-
314
- try
315
- if window.DOMParser
316
- docTests = buildTestsUsing createDocumentUsingParser
317
- createDocumentUsingParser
318
- catch e
319
- docTests = buildTestsUsing createDocumentUsingDOM
320
- createDocumentUsingDOM
321
- finally
322
- for docTest in docTests
323
- return docTest.fallback unless docTest.passes
324
-
263
+ createDocument = (html) ->
264
+ doc = document.documentElement.cloneNode()
265
+ doc.innerHTML = html
266
+ doc.head = doc.querySelector 'head'
267
+ doc.body = doc.querySelector 'body'
268
+ doc
325
269
 
326
270
  # The ComponentUrl class converts a basic URL string into an object
327
271
  # that behaves similarly to document.location.
@@ -514,6 +458,7 @@ class ProgressBar
514
458
  position: fixed;
515
459
  top: 0;
516
460
  left: 0;
461
+ z-index: 2000;
517
462
  background-color: #0076ff;
518
463
  height: 3px;
519
464
  opacity: #{@opacity};
@@ -552,7 +497,6 @@ installHistoryChangeHandler = (event) ->
552
497
  initializeTurbolinks = ->
553
498
  rememberCurrentUrl()
554
499
  rememberCurrentState()
555
- createDocument = browserCompatibleDocumentParser()
556
500
 
557
501
  document.addEventListener 'click', Click.installHandlerLast, true
558
502
 
@@ -1,3 +1,3 @@
1
1
  module Turbolinks
2
- VERSION = '2.5.1'
2
+ VERSION = '2.5.2'
3
3
  end
data/test/config.ru CHANGED
@@ -46,6 +46,10 @@ map "/slow-response" do
46
46
  run SlowResponse.new
47
47
  end
48
48
 
49
+ map "/bounce" do
50
+ run Proc.new{ [200, { "X-XHR-Redirected-To" => "redirect1.html", "Content-Type" => "text/html" }, File.open( File.join( Root, "test", "redirect1.html" ) ) ] }
51
+ end
52
+
49
53
  map "/" do
50
54
  run Rack::Directory.new(File.join(Root, "test"))
51
55
  end
data/test/index.html CHANGED
@@ -31,6 +31,7 @@
31
31
  <li><a href="/other.html" onclick="if(!confirm('follow link?')) { return false}">Confirm Fire Order</a></li>
32
32
  <li><a href="/reload.html"><span>New assets track </span></a></li>
33
33
  <li><a href="/dummy.gif?12345">Query Param Image Link</a></li>
34
+ <li><a href="/bounce">Redirect</a></li>
34
35
  <li><a href="#">Hash link</a></li>
35
36
  <li><a href="/reload.html#foo">New assets track with hash link</a></li>
36
37
  <li><h5>If you stop the server or go into airplane/offline mode</h5></li>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Home</title>
6
+ <script type="text/javascript" src="/js/turbolinks.js"></script>
7
+ </head>
8
+ <body class="page-other">
9
+ Should show /redirect1.html as path
10
+ <ul>
11
+ <li>Click <a href="/redirect2.html">Redirect 2</a></li>
12
+ </ul>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Home</title>
6
+ <script type="text/javascript" src="/js/turbolinks.js"></script>
7
+ </head>
8
+ <body class="page-other">
9
+ Hit back button twice. It should go back to home page.
10
+ </body>
11
+ </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbolinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-rails
@@ -46,6 +46,8 @@ files:
46
46
  - test/manifest.appcache
47
47
  - test/offline.html
48
48
  - test/other.html
49
+ - test/redirect1.html
50
+ - test/redirect2.html
49
51
  - test/reload.html
50
52
  - test/withoutextension
51
53
  homepage: https://github.com/rails/turbolinks/