unpoly-rails 0.60.2 → 0.62.1

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -2
  3. data/CHANGELOG.md +105 -0
  4. data/Rakefile +5 -1
  5. data/dist/unpoly.js +199 -80
  6. data/dist/unpoly.min.js +4 -4
  7. data/lib/assets/javascripts/unpoly/browser.coffee.erb +10 -5
  8. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +21 -12
  9. data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +2 -2
  10. data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +1 -1
  11. data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +11 -3
  12. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +2 -1
  13. data/lib/assets/javascripts/unpoly/element.coffee.erb +4 -4
  14. data/lib/assets/javascripts/unpoly/event.coffee.erb +12 -4
  15. data/lib/assets/javascripts/unpoly/form.coffee.erb +77 -15
  16. data/lib/assets/javascripts/unpoly/fragment.coffee.erb +7 -3
  17. data/lib/assets/javascripts/unpoly/link.coffee.erb +1 -1
  18. data/lib/assets/javascripts/unpoly/modal.coffee.erb +4 -2
  19. data/lib/assets/javascripts/unpoly/motion.coffee.erb +1 -1
  20. data/lib/assets/javascripts/unpoly/protocol.coffee +1 -1
  21. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +3 -4
  22. data/lib/assets/javascripts/unpoly/util.coffee.erb +2 -1
  23. data/lib/assets/javascripts/unpoly/viewport.coffee.erb +26 -2
  24. data/lib/unpoly/rails/version.rb +1 -1
  25. data/package.json +1 -1
  26. data/spec_app/Gemfile +2 -4
  27. data/spec_app/Gemfile.lock +23 -27
  28. data/spec_app/app/views/css_test/modal.erb +1 -1
  29. data/spec_app/app/views/css_test/popup.erb +1 -1
  30. data/spec_app/app/views/pages/start.erb +2 -1
  31. data/spec_app/app/views/replace_test/table.erb +16 -0
  32. data/spec_app/spec/javascripts/up/event_spec.js.coffee +34 -0
  33. data/spec_app/spec/javascripts/up/form_spec.js.coffee +137 -9
  34. data/spec_app/spec/javascripts/up/fragment_spec.js.coffee +36 -1
  35. data/spec_app/spec/javascripts/up/link_spec.js.coffee +7 -2
  36. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +23 -1
  37. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +2 -1
  38. data/spec_app/spec/javascripts/up/util_spec.js.coffee +14 -0
  39. metadata +4 -4
@@ -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) ->
@@ -2452,6 +2465,19 @@ describe 'up.fragment', ->
2452
2465
  expect(destructor).toHaveBeenCalledWith('old text', true)
2453
2466
  done()
2454
2467
 
2468
+ it 'marks the old element as [aria-hidden=true] before destructors', (done) ->
2469
+ destructor = jasmine.createSpy('destructor')
2470
+ up.$compiler '.container', ($element) ->
2471
+ -> destructor($element.text(), $element.is('[aria-hidden=true]'))
2472
+ $container = $fixture('.container').text('old text')
2473
+ up.hello($container)
2474
+
2475
+ destroyDone = up.destroy('.container')
2476
+
2477
+ destroyDone.then ->
2478
+ expect(destructor).toHaveBeenCalledWith('old text', true)
2479
+ done()
2480
+
2455
2481
  it 'marks the old element as .up-destroying before destructors after an { animation }', (done) ->
2456
2482
  destructor = jasmine.createSpy('destructor')
2457
2483
  up.$compiler '.container', ($element) ->
@@ -2533,6 +2559,15 @@ describe 'up.fragment', ->
2533
2559
  )
2534
2560
  expect($element).toBeDetached()
2535
2561
 
2562
+ it 'removes element-related data from the global jQuery cache (bugfix)', asyncSpec (next) ->
2563
+ $element = $fixture('.element')
2564
+ $element.data('foo', { foo: '1' })
2565
+ expect($element.data('foo')).toEqual({ foo: '1'})
2566
+ up.destroy($element)
2567
+
2568
+ next ->
2569
+ expect($element.data('foo')).toBeMissing()
2570
+
2536
2571
  describe 'up.reload', ->
2537
2572
 
2538
2573
  describeCapability 'canPushState', ->
@@ -928,9 +928,14 @@ describe 'up.link', ->
928
928
  Trigger.mouseup(@$link)
929
929
  next => expect(@followSpy).not.toHaveBeenCalled()
930
930
 
931
- it 'does nothing on click', asyncSpec (next)->
931
+ it 'does nothing on click if there was an earlier mousedown event', asyncSpec (next)->
932
+ Trigger.mousedown(@$link)
932
933
  Trigger.click(@$link)
933
- next => expect(@followSpy).not.toHaveBeenCalled()
934
+ next => expect(@followSpy.calls.count()).toBe(1)
935
+
936
+ it 'does follow a link on click if there was never a mousedown event (e.g. if the user pressed enter)', asyncSpec (next) ->
937
+ Trigger.click(@$link)
938
+ next => expect(@followSpy.calls.mostRecent().args[0]).toEqual(@$link[0])
934
939
 
935
940
  # IE does not call JavaScript and always performs the default action on right clicks
936
941
  unless AgentDetector.isIE() || AgentDetector.isEdge()
@@ -532,8 +532,9 @@ describe 'up.modal', ->
532
532
  next => expect(@followSpy).not.toHaveBeenCalled()
533
533
 
534
534
  it 'does nothing on click', asyncSpec (next) ->
535
+ Trigger.mousedown(@$link)
535
536
  Trigger.click(@$link)
536
- next => expect(@followSpy).not.toHaveBeenCalled()
537
+ next => expect(@followSpy.calls.count()).toBe(1)
537
538
 
538
539
  # IE does not call JavaScript and always performs the default action on right clicks
539
540
  unless AgentDetector.isIE() || AgentDetector.isEdge()
@@ -562,6 +563,27 @@ describe 'up.modal', ->
562
563
  next =>
563
564
  expect(@lastRequest().method).toEqual 'POST'
564
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
+
565
587
  it 'adds a history entry and allows the user to use the back button', asyncSpec (next) ->
566
588
  up.motion.config.enabled = false
567
589
  up.history.config.enabled = true
@@ -232,8 +232,9 @@ describe 'up.popup', ->
232
232
  next => expect(@attachSpy).not.toHaveBeenCalled()
233
233
 
234
234
  it 'does nothing on click', asyncSpec (next) ->
235
+ Trigger.mousedown(@$link)
235
236
  Trigger.click(@$link)
236
- next => expect(@attachSpy).not.toHaveBeenCalled()
237
+ next => expect(@attachSpy.calls.count()).toBe(1)
237
238
 
238
239
  # IE does not call JavaScript and always performs the default action on right clicks
239
240
  unless AgentDetector.isIE() || AgentDetector.isEdge()
@@ -1404,3 +1404,17 @@ describe 'up.util', ->
1404
1404
  it 'returns false for NaN', ->
1405
1405
  value = NaN
1406
1406
  expect(up.util.isList(value)).toBe(false)
1407
+
1408
+ describe 'up.util.isJQuery', ->
1409
+
1410
+ it 'returns true for a jQuery collection', ->
1411
+ value = $('body')
1412
+ expect(up.util.isJQuery(value)).toBe(true)
1413
+
1414
+ it 'returns false for a native element', ->
1415
+ value = document.body
1416
+ expect(up.util.isJQuery(value)).toBe(false)
1417
+
1418
+ it 'returns false (and does not crash) for undefined', ->
1419
+ value = undefined
1420
+ expect(up.util.isJQuery(value)).toBe(false)
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.60.2
4
+ version: 0.62.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-03 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -232,6 +232,7 @@ files:
232
232
  - spec_app/app/views/replace_test/_nav.erb
233
233
  - spec_app/app/views/replace_test/page1.erb
234
234
  - spec_app/app/views/replace_test/page2.erb
235
+ - spec_app/app/views/replace_test/table.erb
235
236
  - spec_app/app/views/reveal_test/long1.erb
236
237
  - spec_app/app/views/reveal_test/long2.erb
237
238
  - spec_app/app/views/reveal_test/within_document_viewport.erb
@@ -399,8 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
399
400
  - !ruby/object:Gem::Version
400
401
  version: '0'
401
402
  requirements: []
402
- rubyforge_project:
403
- rubygems_version: 2.7.6
403
+ rubygems_version: 3.0.8
404
404
  signing_key:
405
405
  specification_version: 4
406
406
  summary: Rails bindings for Unpoly, the unobtrusive JavaScript framework