turbograft 0.1.18 → 0.1.19

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: 162a4e5cbd1a2e3e811dbdc2ec28924af612a221
4
- data.tar.gz: 6ec6f20017bb47580ba5bdfeff2f24b0c5612f5a
3
+ metadata.gz: 55e884d9cae78a5f4b29a9db09219330691ae419
4
+ data.tar.gz: 22397cb8a4d242ed433f095356f73ac65d2dad17
5
5
  SHA512:
6
- metadata.gz: 09a4a0ffc527f89b0eca473b66f24316508eed295fc216fc7ec37dd86f047ac69eb168e40bb277a501fcfc518f5eec758542fdec13cc3740df5334b172595eab
7
- data.tar.gz: 5857f7123cfa70f38e3a45037cb2e788bb2724384337d7fdd6d2d366bf8e6e56ab6bbc6ab8cb430ae4c8cbc04c996083a67529be40283c69fd53ae6475491a5c
6
+ metadata.gz: 57d534662c27201f329d9882ea0406ad9cbb74ceae59a47ee69069b43155f55a824aa1438f16bfaa18e12743688a03c7a6bf41e9cd0acaed0be63c634807f690
7
+ data.tar.gz: 4319802f8a1ab14ab9913068515baaaf6a357507f39fef41804dd24cc03d62a87c02bc4c1afa1c7c0d2237a5ee1b24d950585d5046971f2702e61a8c3ef58fd2
data/README.md CHANGED
@@ -20,9 +20,10 @@ Turbograft was built with simplicity in mind. It intends to offer the smallest a
20
20
 
21
21
  ## Installation
22
22
 
23
- * Add `gem "turbograft"` to your Gemfile
23
+ * Replace `gem "turbolinks"` with `gem "turbograft"` in your Gemfile
24
+ * Replace `//= require turbolinks` with `//= require turbograft` in _app/assets/javascripts/application.js_
24
25
  * Run `bundle install`
25
- * Add `#= require turbograft` to _app/assets/javascripts/application.js_
26
+
26
27
 
27
28
  ## Usage
28
29
  ### Partial page refresh
@@ -303,7 +303,7 @@ class window.Turbolinks
303
303
  xhr.getResponseHeader('Content-Type').match /^(?:text\/html|application\/xhtml\+xml|application\/xml)(?:;|$)/
304
304
 
305
305
  extractTrackAssets = (doc) ->
306
- for node in doc.head.childNodes when node.getAttribute?('data-turbolinks-track')?
306
+ for node in doc.querySelector('head').childNodes when node.getAttribute?('data-turbolinks-track')?
307
307
  node.getAttribute('src') or node.getAttribute('href')
308
308
 
309
309
  assetsChanged = (doc) ->
@@ -324,7 +324,7 @@ class window.Turbolinks
324
324
 
325
325
  extractTitleAndBody = (doc) ->
326
326
  title = doc.querySelector 'title'
327
- [ title?.textContent, removeNoscriptTags(doc.body), CSRFToken.get(doc).token, 'runScripts' ]
327
+ [ title?.textContent, removeNoscriptTags(doc.querySelector('body')), CSRFToken.get(doc).token, 'runScripts' ]
328
328
 
329
329
  installHistoryChangeHandler = (event) ->
330
330
  if event.state?.turbolinks
@@ -335,48 +335,21 @@ class window.Turbolinks
335
335
  bypassOnLoadPopstate = (fn) ->
336
336
  setTimeout fn, 500
337
337
 
338
- browserCompatibleDocumentParser = ->
339
- createDocumentUsingParser = (html) ->
340
- (new DOMParser).parseFromString html, 'text/html'
341
-
342
- createDocumentUsingDOM = (html) ->
343
- doc = document.implementation.createHTMLDocument ''
344
- doc.documentElement.innerHTML = html
345
- doc
346
-
347
- createDocumentUsingWrite = (html) ->
348
- doc = document.implementation.createHTMLDocument ''
349
- doc.open 'replace'
350
- doc.write html
351
- doc.close()
352
- doc
353
-
354
- # Use createDocumentUsingParser if DOMParser is defined and natively
355
- # supports 'text/html' parsing (Firefox 12+, IE 10)
356
- #
357
- # Use createDocumentUsingDOM if createDocumentUsingParser throws an exception
358
- # due to unsupported type 'text/html' (Firefox < 12, Opera)
359
- #
360
- # Use createDocumentUsingWrite if:
361
- # - DOMParser isn't defined
362
- # - createDocumentUsingParser returns null due to unsupported type 'text/html' (Chrome, Safari)
363
- # - createDocumentUsingDOM doesn't create a valid HTML document (safeguarding against potential edge cases)
364
- try
365
- if window.DOMParser
366
- testDoc = createDocumentUsingParser '<html><body><p>test'
367
- createDocumentUsingParser
368
- catch e
369
- testDoc = createDocumentUsingDOM '<html><body><p>test'
370
- createDocumentUsingDOM
371
- finally
372
- unless testDoc?.body?.childNodes.length is 1
373
- return createDocumentUsingWrite
338
+ createDocument = (html) ->
339
+ if /<(html|body)/i.test(html)
340
+ doc = document.documentElement.cloneNode()
341
+ doc.innerHTML = html
342
+ else
343
+ doc = document.documentElement.cloneNode(true)
344
+ doc.querySelector('body').innerHTML = html
345
+ doc.head = doc.querySelector('head')
346
+ doc.body = doc.querySelector('body')
347
+ doc
374
348
 
375
349
  if browserSupportsTurbolinks
376
350
  @visit = fetch
377
351
  @rememberCurrentUrl()
378
352
  @rememberCurrentState()
379
- createDocument = browserCompatibleDocumentParser()
380
353
 
381
354
  document.addEventListener 'click', Click.installHandlerLast, true
382
355
 
@@ -1,3 +1,3 @@
1
1
  module TurboGraft
2
- VERSION = '0.1.18'
2
+ VERSION = '0.1.19'
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.1.18
4
+ version: 0.1.19
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: 2015-04-22 00:00:00.000000000 Z
16
+ date: 2015-06-03 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: coffee-rails
@@ -128,7 +128,7 @@ dependencies:
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  - !ruby/object:Gem::Dependency
131
- name: teaspoon
131
+ name: teaspoon-mocha
132
132
  requirement: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - ">="
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubyforge_project:
259
- rubygems_version: 2.2.2
259
+ rubygems_version: 2.2.3
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: turbolinks with partial page replacement