unpoly-rails 0.62.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of unpoly-rails might be problematic. Click here for more details.

Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +47 -0
  3. data/Gemfile +0 -1
  4. data/Gemfile.lock +1 -7
  5. data/README.md +7 -6
  6. data/Rakefile +11 -2
  7. data/dist/unpoly.js +75 -49
  8. data/dist/unpoly.min.js +4 -4
  9. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +21 -12
  10. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +1 -0
  11. data/lib/assets/javascripts/unpoly/classes/request.coffee +1 -0
  12. data/lib/assets/javascripts/unpoly/element.coffee.erb +5 -2
  13. data/lib/assets/javascripts/unpoly/form.coffee.erb +16 -1
  14. data/lib/assets/javascripts/unpoly/framework.coffee +8 -10
  15. data/lib/assets/javascripts/unpoly/log.coffee +7 -2
  16. data/lib/assets/javascripts/unpoly/modal.coffee.erb +1 -0
  17. data/lib/assets/javascripts/unpoly/motion.coffee.erb +1 -1
  18. data/lib/assets/javascripts/unpoly/protocol.coffee +2 -0
  19. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +2 -3
  20. data/lib/assets/javascripts/unpoly/util.coffee.erb +2 -1
  21. data/lib/unpoly/rails/version.rb +1 -1
  22. data/package.json +1 -1
  23. data/spec_app/Gemfile +0 -1
  24. data/spec_app/Gemfile.lock +1 -7
  25. data/spec_app/app/assets/javascripts/integration_test.coffee +0 -1
  26. data/spec_app/app/controllers/boot_test_controller.rb +31 -0
  27. data/spec_app/app/controllers/pages_controller.rb +8 -0
  28. data/spec_app/app/helpers/application_helper.rb +9 -0
  29. data/spec_app/app/views/boot_test/defer.erb +18 -0
  30. data/spec_app/app/views/boot_test/module.erb +18 -0
  31. data/spec_app/app/views/boot_test/sync.erb +17 -0
  32. data/spec_app/app/views/compiler_test/timestamp.erb +1 -0
  33. data/spec_app/app/views/css_test/modal.erb +1 -1
  34. data/spec_app/app/views/css_test/popup.erb +1 -1
  35. data/spec_app/app/views/form_test/redirects/target.erb +2 -0
  36. data/spec_app/app/views/layouts/integration_test.erb +3 -3
  37. data/spec_app/app/views/pages/start.erb +3 -0
  38. data/spec_app/config/routes.rb +3 -0
  39. data/spec_app/spec/javascripts/helpers/knife.js.coffee +1 -1
  40. data/spec_app/spec/javascripts/up/fragment_spec.js.coffee +14 -1
  41. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +21 -0
  42. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +8 -0
  43. data/spec_app/spec/javascripts/up/util_spec.js.coffee +14 -0
  44. metadata +7 -3
@@ -0,0 +1,17 @@
1
+ <%= include_user_script(delay: 2) %>
2
+
3
+ <h1>Booting (sync scripts)</h1>
4
+
5
+ <h2>Setup</h2>
6
+
7
+ <ul>
8
+ <li>Both Unpoly and user script have loaded synchronously (blocking the DOM parser).</li>
9
+ <li>The user script took intentionally long to render.</li>
10
+ </ul>
11
+
12
+ <h2>Expectations</h2>
13
+
14
+ <ul>
15
+ <li>Unpoly has booted automatically after the user script was called.</li>
16
+ <li>The background should be red (from a user script compiler).</li>
17
+ </ul>
@@ -7,3 +7,4 @@
7
7
 
8
8
  <div class="timestamp">
9
9
  Uncompiled
10
+ </div>
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  var u = up.util;
3
- up.compiler('.clamped-open', function($link) {
3
+ up.$compiler('.clamped-open', function($link) {
4
4
  $link.on('click', function(event) {
5
5
  event.preventDefault();
6
6
  u.task(function() {
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  var u = up.util;
3
- up.compiler('.clamped-open', function(link) {
3
+ up.$compiler('.clamped-open', function(link) {
4
4
  link.addEventListener('click', function(event) {
5
5
  event.preventDefault();
6
6
  u.task(function() {
@@ -1,4 +1,6 @@
1
1
  <div class="example">
2
2
  <p>Redirect target reached</p>
3
3
  <p>URL should be <code><%= target_form_test_redirect_path %></code></p>
4
+ <p><code>X-Up-Target</code> request header is <code><%= request.headers['X-Up-Target'] %></code></p>
5
+ <p><code>X-Up-Version</code> request header is <code><%= request.headers['X-Up-Version'] %></code></p>
4
6
  </div>
@@ -3,12 +3,12 @@
3
3
  <head>
4
4
  <title>Integration test - Unpoly</title>
5
5
  <%= stylesheet_link_tag 'integration_test', media: 'all' %>
6
- <%= javascript_include_tag 'integration_test' %>
6
+ <%= javascript_include_tag 'integration_test', script_options %>
7
7
  <% if params[:bootstrap] == '1' %>
8
8
  <%= stylesheet_link_tag 'bootstrap_manifest', media: 'all' %>
9
- <%= javascript_include_tag 'bootstrap_manifest' %>
9
+ <%= javascript_include_tag 'bootstrap_manifest', script_options %>
10
10
  <%= stylesheet_link_tag 'unpoly-bootstrap3', media: 'all' %>
11
- <%= javascript_include_tag 'unpoly-bootstrap3' %>
11
+ <%= javascript_include_tag 'unpoly-bootstrap3', script_options %>
12
12
  <% end %>
13
13
  <%= csrf_meta_tags %>
14
14
  <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'>
@@ -74,6 +74,9 @@
74
74
  <li><%= link_to 'Animations', '/motion_test/animations' %></li>
75
75
  <li><%= link_to 'Transitions', '/motion_test/transitions' %></li>
76
76
  <li><%= link_to 'Compilers', '/compiler_test/timestamp' %></li>
77
+ <li><%= link_to 'Booting (sync scripts)', '/boot_test/sync' %></li>
78
+ <li><%= link_to 'Booting (defer scripts)', '/boot_test/defer' %></li>
79
+ <li><%= link_to 'Booting (module scripts)', '/boot_test/module' %></li>
77
80
  </ul>
78
81
 
79
82
  </div>
@@ -3,6 +3,8 @@ Rails.application.routes.draw do
3
3
  mount JasmineRails::Engine => '/specs' if defined?(JasmineRails)
4
4
  root to: 'pages#start'
5
5
 
6
+ get 'pages/:action', controller: 'pages'
7
+
6
8
  get 'method_test/:action', controller: 'method_test'
7
9
  post 'method_test/:action', controller: 'method_test'
8
10
 
@@ -16,6 +18,7 @@ Rails.application.routes.draw do
16
18
  get 'scroll_test/:action', controller: 'scroll_test'
17
19
  get 'motion_test/:action', controller: 'motion_test'
18
20
  get 'compiler_test/:action', controller: 'compiler_test'
21
+ get 'boot_test/:action', controller: 'boot_test'
19
22
 
20
23
  namespace :form_test do
21
24
  resource :basic, only: [:new, :create]
@@ -28,7 +28,7 @@
28
28
  # klass.publicMethod() # => 'mocked!'
29
29
  # expect(spy).toHaveBeenCalled()
30
30
  #
31
- @Knife = (->
31
+ window.Knife = (->
32
32
 
33
33
  contextBleeder = ->
34
34
 
@@ -2432,13 +2432,26 @@ describe 'up.fragment', ->
2432
2432
  expect($element).toBeDetached()
2433
2433
 
2434
2434
  it 'calls destructors for custom elements', (done) ->
2435
- up.$compiler('.element', ($element) -> destructor)
2436
2435
  destructor = jasmine.createSpy('destructor')
2436
+ up.$compiler('.element', ($element) -> destructor)
2437
2437
  up.hello(fixture('.element'))
2438
2438
  up.destroy('.element').then ->
2439
2439
  expect(destructor).toHaveBeenCalled()
2440
2440
  done()
2441
2441
 
2442
+ it 'does not call destructors twice if up.destroy() is called twice on the same fragment', asyncSpec (next) ->
2443
+ destructor = jasmine.createSpy('destructor')
2444
+ up.compiler('.element', (element) -> destructor)
2445
+
2446
+ element = fixture('.element')
2447
+ up.hello(element)
2448
+
2449
+ up.destroy(element, animation: 'fade-out', duration: 10)
2450
+ up.destroy(element, animation: 'fade-out', duration: 10)
2451
+
2452
+ next.after 60, ->
2453
+ expect(destructor.calls.count()).toBe(1)
2454
+
2442
2455
  it 'marks the old element as .up-destroying before destructors', (done) ->
2443
2456
  destructor = jasmine.createSpy('destructor')
2444
2457
  up.$compiler '.container', ($element) ->
@@ -563,6 +563,27 @@ describe 'up.modal', ->
563
563
  next =>
564
564
  expect(@lastRequest().method).toEqual 'POST'
565
565
 
566
+ describe 'with [up-cache] modifier', ->
567
+ it 'honours the given setting', asyncSpec (next) ->
568
+ $link = $fixture('a[href="/path"][up-modal=".target"][up-cache="false"]')
569
+ Trigger.clickSequence($link)
570
+
571
+ next =>
572
+ @respondWith('<div class="target">modal content 1</div>')
573
+
574
+ next =>
575
+ expect('.up-modal .target').toHaveText('modal content 1')
576
+ history.back()
577
+
578
+ next =>
579
+ Trigger.clickSequence($link)
580
+
581
+ next =>
582
+ @respondWith('<div class="target">modal content 2</div>')
583
+
584
+ next =>
585
+ expect('.up-modal .target').toHaveText('modal content 2')
586
+
566
587
  it 'adds a history entry and allows the user to use the back button', asyncSpec (next) ->
567
588
  up.motion.config.enabled = false
568
589
  up.history.config.enabled = true
@@ -38,6 +38,14 @@ describe 'up.proxy', ->
38
38
  expect(request.requestHeaders['X-Up-Target']).toEqual('.target')
39
39
  expect(request.requestHeaders['X-Up-Fail-Target']).toEqual('.fail-target')
40
40
 
41
+ it "sends Unpoly's version as an X-Up-Version request header", asyncSpec (next) ->
42
+ up.request(url: '/foo')
43
+
44
+ next =>
45
+ versionHeader = @lastRequest().requestHeaders['X-Up-Version']
46
+ expect(versionHeader).toBePresent()
47
+ expect(versionHeader).toEqual(up.version)
48
+
41
49
  it 'resolves to a Response object that contains information about the response and request', (done) ->
42
50
  promise = up.request(
43
51
  url: '/url'
@@ -1418,3 +1418,17 @@ describe 'up.util', ->
1418
1418
  it 'returns false (and does not crash) for undefined', ->
1419
1419
  value = undefined
1420
1420
  expect(up.util.isJQuery(value)).toBe(false)
1421
+
1422
+ describe 'up.util.escapeHtml', ->
1423
+
1424
+ it 'escapes double quotes', ->
1425
+ result = up.util.escapeHtml('before"after')
1426
+ expect(result).toEqual('before&quot;after')
1427
+
1428
+ it 'escapes single quotes', ->
1429
+ result = up.util.escapeHtml("before'after")
1430
+ expect(result).toEqual('before&#x27;after')
1431
+
1432
+ it 'escapes angle brackets', ->
1433
+ result = up.util.escapeHtml('before<script>after')
1434
+ expect(result).toEqual('before&lt;script&gt;after')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unpoly-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.62.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2021-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -189,6 +189,7 @@ files:
189
189
  - spec_app/app/assets/stylesheets/jasmine_specs.sass
190
190
  - spec_app/app/controllers/application_controller.rb
191
191
  - spec_app/app/controllers/binding_test_controller.rb
192
+ - spec_app/app/controllers/boot_test_controller.rb
192
193
  - spec_app/app/controllers/compiler_test_controller.rb
193
194
  - spec_app/app/controllers/css_test_controller.rb
194
195
  - spec_app/app/controllers/error_test_controller.rb
@@ -205,6 +206,9 @@ files:
205
206
  - spec_app/app/helpers/application_helper.rb
206
207
  - spec_app/app/mailers/.keep
207
208
  - spec_app/app/models/concerns/.keep
209
+ - spec_app/app/views/boot_test/defer.erb
210
+ - spec_app/app/views/boot_test/module.erb
211
+ - spec_app/app/views/boot_test/sync.erb
208
212
  - spec_app/app/views/compiler_test/timestamp.erb
209
213
  - spec_app/app/views/css_test/modal.erb
210
214
  - spec_app/app/views/css_test/modal_contents.erb
@@ -400,7 +404,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
400
404
  - !ruby/object:Gem::Version
401
405
  version: '0'
402
406
  requirements: []
403
- rubygems_version: 3.0.8
407
+ rubygems_version: 3.2.16
404
408
  signing_key:
405
409
  specification_version: 4
406
410
  summary: Rails bindings for Unpoly, the unobtrusive JavaScript framework