unpoly-rails 0.57.0 → 0.60.0

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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +393 -1
  3. data/Gemfile.lock +5 -2
  4. data/README.md +1 -1
  5. data/README_RAILS.md +1 -1
  6. data/Rakefile +10 -1
  7. data/design/es6.js +32 -0
  8. data/design/ie11.txt +9 -0
  9. data/design/measure_jquery/element_list.js +41 -0
  10. data/design/measure_jquery/up.on_vs_addEventListener.js +56 -0
  11. data/design/todo_jquery.txt +13 -0
  12. data/dist/unpoly-bootstrap3.js +8 -8
  13. data/dist/unpoly-bootstrap3.min.js +1 -1
  14. data/dist/unpoly.css +22 -20
  15. data/dist/unpoly.js +6990 -5336
  16. data/dist/unpoly.min.css +1 -1
  17. data/dist/unpoly.min.js +4 -4
  18. data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +5 -0
  19. data/lib/assets/javascripts/unpoly.coffee +8 -6
  20. data/lib/assets/javascripts/unpoly/browser.coffee.erb +23 -118
  21. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +36 -0
  22. data/lib/assets/javascripts/unpoly/classes/cache.coffee +4 -4
  23. data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +45 -39
  24. data/lib/assets/javascripts/unpoly/classes/config.coffee +9 -0
  25. data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +18 -27
  26. data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +39 -0
  27. data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +116 -0
  28. data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +8 -8
  29. data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +19 -19
  30. data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +54 -31
  31. data/lib/assets/javascripts/unpoly/classes/{focus_tracker.coffee → focus_follower.coffee} +2 -2
  32. data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +25 -25
  33. data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +4 -11
  34. data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +157 -0
  35. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +525 -0
  36. data/lib/assets/javascripts/unpoly/classes/record.coffee +8 -2
  37. data/lib/assets/javascripts/unpoly/classes/rect.js +21 -0
  38. data/lib/assets/javascripts/unpoly/classes/request.coffee +41 -35
  39. data/lib/assets/javascripts/unpoly/classes/response.coffee +7 -3
  40. data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +102 -0
  41. data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +67 -0
  42. data/lib/assets/javascripts/unpoly/classes/selector.coffee +60 -0
  43. data/lib/assets/javascripts/unpoly/classes/tether.coffee +105 -0
  44. data/lib/assets/javascripts/unpoly/classes/url_set.coffee +12 -7
  45. data/lib/assets/javascripts/unpoly/element.coffee.erb +1126 -0
  46. data/lib/assets/javascripts/unpoly/event.coffee.erb +437 -0
  47. data/lib/assets/javascripts/unpoly/feedback.coffee +73 -94
  48. data/lib/assets/javascripts/unpoly/form.coffee.erb +188 -181
  49. data/lib/assets/javascripts/unpoly/{dom.coffee.erb → fragment.coffee.erb} +250 -283
  50. data/lib/assets/javascripts/unpoly/framework.coffee +67 -0
  51. data/lib/assets/javascripts/unpoly/history.coffee +29 -28
  52. data/lib/assets/javascripts/unpoly/legacy.coffee +60 -0
  53. data/lib/assets/javascripts/unpoly/link.coffee.erb +127 -119
  54. data/lib/assets/javascripts/unpoly/log.coffee +99 -19
  55. data/lib/assets/javascripts/unpoly/modal.coffee.erb +95 -118
  56. data/lib/assets/javascripts/unpoly/motion.coffee.erb +158 -138
  57. data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
  58. data/lib/assets/javascripts/unpoly/popup.coffee.erb +119 -102
  59. data/lib/assets/javascripts/unpoly/protocol.coffee +11 -15
  60. data/lib/assets/javascripts/unpoly/proxy.coffee +62 -65
  61. data/lib/assets/javascripts/unpoly/radio.coffee +3 -5
  62. data/lib/assets/javascripts/unpoly/rails.coffee +8 -9
  63. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +173 -125
  64. data/lib/assets/javascripts/unpoly/toast.coffee +25 -24
  65. data/lib/assets/javascripts/unpoly/tooltip.coffee +89 -79
  66. data/lib/assets/javascripts/unpoly/util.coffee.erb +579 -1074
  67. data/lib/assets/javascripts/unpoly/{layout.coffee.erb → viewport.coffee.erb} +334 -264
  68. data/lib/assets/stylesheets/unpoly/dom.sass +1 -1
  69. data/lib/assets/stylesheets/unpoly/layout.sass +2 -0
  70. data/lib/assets/stylesheets/unpoly/popup.sass +0 -1
  71. data/lib/assets/stylesheets/unpoly/tooltip.sass +17 -12
  72. data/lib/unpoly/rails/version.rb +1 -1
  73. data/package.json +1 -2
  74. data/spec_app/Gemfile +2 -1
  75. data/spec_app/Gemfile.lock +38 -27
  76. data/spec_app/app/assets/javascripts/integration_test.coffee +1 -0
  77. data/spec_app/app/assets/javascripts/jasmine_specs.coffee +1 -2
  78. data/spec_app/app/assets/stylesheets/integration_test.sass +14 -1
  79. data/spec_app/app/controllers/scroll_test_controller.rb +5 -0
  80. data/spec_app/app/views/css_test/modal.erb +6 -6
  81. data/spec_app/app/views/css_test/popup.erb +44 -18
  82. data/spec_app/app/views/css_test/tooltip.erb +23 -4
  83. data/spec_app/app/views/error_test/trigger.erb +1 -1
  84. data/spec_app/app/views/form_test/basics/new.erb +1 -3
  85. data/spec_app/app/views/pages/start.erb +9 -2
  86. data/spec_app/app/views/reveal_test/long1.erb +1 -1
  87. data/spec_app/app/views/reveal_test/long2.erb +1 -1
  88. data/spec_app/app/views/reveal_test/within_document_viewport.erb +24 -0
  89. data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +28 -0
  90. data/spec_app/app/views/scroll_test/long1.erb +30 -0
  91. data/spec_app/config/routes.rb +1 -0
  92. data/spec_app/spec/javascripts/helpers/agent_detector.coffee +3 -0
  93. data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +1 -0
  94. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +17 -5
  95. data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +1 -1
  96. data/spec_app/spec/javascripts/helpers/fixture.js.coffee +25 -0
  97. data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +1 -0
  98. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +1 -0
  99. data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +1 -1
  100. data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +2 -2
  101. data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +4 -1
  102. data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +3 -0
  103. data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +2 -1
  104. data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +2 -2
  105. data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +18 -11
  106. data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +3 -0
  107. data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +3 -0
  108. data/spec_app/spec/javascripts/helpers/spec_util.coffee +47 -0
  109. data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +3 -0
  110. data/spec_app/spec/javascripts/helpers/to_be_array.coffee +5 -0
  111. data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +6 -2
  112. data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +3 -0
  113. data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +6 -2
  114. data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +8 -0
  115. data/spec_app/spec/javascripts/helpers/to_be_error.coffee +3 -0
  116. data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +3 -0
  117. data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +8 -0
  118. data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +3 -0
  119. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +3 -0
  120. data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +3 -0
  121. data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +9 -0
  122. data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +3 -0
  123. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +3 -0
  124. data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +1 -2
  125. data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +7 -0
  126. data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +7 -0
  127. data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +10 -0
  128. data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +10 -0
  129. data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +8 -0
  130. data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +7 -3
  131. data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +3 -0
  132. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +1 -0
  133. data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +9 -0
  134. data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -21
  135. data/spec_app/spec/javascripts/helpers/to_match_list.coffee +14 -0
  136. data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +3 -0
  137. data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +4 -1
  138. data/spec_app/spec/javascripts/helpers/to_match_url.coffee +1 -0
  139. data/spec_app/spec/javascripts/helpers/trigger.js.coffee +91 -7
  140. data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +3 -0
  141. data/spec_app/spec/javascripts/up/browser_spec.js.coffee +23 -90
  142. data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +3 -0
  143. data/spec_app/spec/javascripts/up/classes/config_spec.coffee +24 -0
  144. data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +45 -0
  145. data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +5 -2
  146. data/spec_app/spec/javascripts/up/classes/params_spec.coffee +557 -0
  147. data/spec_app/spec/javascripts/up/classes/request_spec.coffee +7 -4
  148. data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +51 -0
  149. data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +3 -0
  150. data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +3 -2
  151. data/spec_app/spec/javascripts/up/element_spec.coffee +897 -0
  152. data/spec_app/spec/javascripts/up/event_spec.js.coffee +496 -0
  153. data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +69 -48
  154. data/spec_app/spec/javascripts/up/form_spec.js.coffee +252 -194
  155. data/spec_app/spec/javascripts/up/{dom_spec.js.coffee → fragment_spec.js.coffee} +381 -388
  156. data/spec_app/spec/javascripts/up/history_spec.js.coffee +21 -19
  157. data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +4 -0
  158. data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +27 -0
  159. data/spec_app/spec/javascripts/up/link_spec.js.coffee +163 -160
  160. data/spec_app/spec/javascripts/up/log_spec.js.coffee +85 -12
  161. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +141 -123
  162. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +117 -113
  163. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +60 -77
  164. data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +1 -0
  165. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +85 -78
  166. data/spec_app/spec/javascripts/up/radio_spec.js.coffee +29 -22
  167. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +14 -13
  168. data/spec_app/spec/javascripts/up/spec_spec.js.coffee +9 -0
  169. data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +96 -66
  170. data/spec_app/spec/javascripts/up/toast_spec.js.coffee +37 -0
  171. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +31 -47
  172. data/spec_app/spec/javascripts/up/util_spec.js.coffee +725 -562
  173. data/spec_app/spec/javascripts/up/{layout_spec.js.coffee → viewport_spec.js.coffee} +175 -149
  174. metadata +57 -19
  175. data/lib/assets/javascripts/unpoly-bootstrap3/layout-ext.coffee +0 -5
  176. data/lib/assets/javascripts/unpoly/bus.coffee.erb +0 -518
  177. data/lib/assets/javascripts/unpoly/classes/extract_step.coffee +0 -4
  178. data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +0 -125
  179. data/lib/assets/javascripts/unpoly/params.coffee.erb +0 -522
  180. data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +0 -8
  181. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +0 -210
  182. data/spec_app/spec/javascripts/up/namespace_spec.js.coffee +0 -9
  183. data/spec_app/spec/javascripts/up/params_spec.coffee +0 -768
  184. data/spec_app/vendor/asset-libs/jasmine-fixture-1.3.4/jasmine-fixture.js +0 -433
  185. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/.bower.json +0 -26
  186. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/jasmine-jquery.js +0 -838
@@ -1,3 +1,6 @@
1
+ u = up.util
2
+ $ = jQuery
3
+
1
4
  describe 'up.log', ->
2
5
 
3
6
  describe 'JavaScript functions', ->
@@ -5,42 +8,112 @@ describe 'up.log', ->
5
8
  describe 'up.log.puts', ->
6
9
 
7
10
  it 'sends a log message to the developer console iff the log is enabled', ->
8
- spyOn(up.browser, 'puts')
11
+ spyOn(console, 'log')
9
12
 
10
13
  up.log.disable()
11
14
  up.log.puts('message')
12
- expect(up.browser.puts).not.toHaveBeenCalled()
15
+ expect(console.log).not.toHaveBeenCalled()
13
16
 
14
17
  up.log.enable()
15
18
  up.log.puts('message')
16
- expect(up.browser.puts).toHaveBeenCalledWith('log', '[UP] message')
19
+ expect(console.log).toHaveBeenCalledWith('[UP] message')
17
20
 
18
21
  describe 'up.log.debug', ->
19
22
 
20
23
  it 'sends a debug message to the developer console iff the log is enabled', ->
21
- spyOn(up.browser, 'puts')
24
+ spyOn(console, 'debug')
22
25
 
23
26
  up.log.disable()
24
27
  up.log.debug('message')
25
- expect(up.browser.puts).not.toHaveBeenCalled()
28
+ expect(console.debug).not.toHaveBeenCalled()
26
29
 
27
30
  up.log.enable()
28
31
  up.log.debug('message')
29
- expect(up.browser.puts).toHaveBeenCalledWith('debug', '[UP] message')
32
+ expect(console.debug).toHaveBeenCalledWith('[UP] message')
30
33
 
31
34
  describe 'up.log.error', ->
32
35
 
33
36
  it 'sends an error message to the developer console regardless whether the log is enabled or not', ->
34
- spyOn(up.browser, 'puts')
37
+ spyOn(console, 'error')
35
38
 
36
39
  up.log.disable()
37
40
  up.log.error('message1')
38
- expect(up.browser.puts).toHaveBeenCalledWith('error', '[UP] message1')
41
+ expect(console.error).toHaveBeenCalledWith('[UP] message1')
39
42
 
40
43
  up.log.enable()
41
44
  up.log.error('message2')
42
- expect(up.browser.puts.calls.allArgs()).toEqual [
43
- ['error', '[UP] message1'],
44
- ['error', '[UP] message2']
45
+ expect(console.error.calls.allArgs()).toEqual [
46
+ ['[UP] message1'],
47
+ ['[UP] message2']
45
48
  ]
46
-
49
+
50
+ describe 'up.log.sprintf', ->
51
+
52
+ describe 'with string argument', ->
53
+
54
+ it 'serializes with surrounding quotes', ->
55
+ formatted = up.log.sprintf('before %o after', 'argument')
56
+ expect(formatted).toEqual('before "argument" after')
57
+
58
+ describe 'with undefined argument', ->
59
+
60
+ it 'serializes to the word "undefined"', ->
61
+ formatted = up.log.sprintf('before %o after', undefined)
62
+ expect(formatted).toEqual('before undefined after')
63
+
64
+ describe 'with null argument', ->
65
+
66
+ it 'serializes to the word "null"', ->
67
+ formatted = up.log.sprintf('before %o after', null)
68
+ expect(formatted).toEqual('before null after')
69
+
70
+ describe 'with number argument', ->
71
+
72
+ it 'serializes the number as string', ->
73
+ formatted = up.log.sprintf('before %o after', 5)
74
+ expect(formatted).toEqual('before 5 after')
75
+
76
+ describe 'with function argument', ->
77
+
78
+ it 'serializes the function code', ->
79
+ formatted = up.log.sprintf('before %o after', `function foo() {}`)
80
+ expect(formatted).toEqual('before function foo() {} after')
81
+
82
+ describe 'with array argument', ->
83
+
84
+ it 'recursively serializes the elements', ->
85
+ formatted = up.log.sprintf('before %o after', [1, "foo"])
86
+ expect(formatted).toEqual('before [1, "foo"] after')
87
+
88
+ describe 'with element argument', ->
89
+
90
+ it 'serializes the tag name with id, name and class attributes, but ignores other attributes', ->
91
+ $element = $('<table id="id-value" name="name-value" class="class-value" title="title-value">')
92
+ element = $element.get(0)
93
+ formatted = up.log.sprintf('before %o after', element)
94
+ expect(formatted).toEqual('before <table id="id-value" name="name-value" class="class-value"> after')
95
+
96
+ describe 'with jQuery argument', ->
97
+
98
+ it 'serializes the tag name with id, name and class attributes, but ignores other attributes', ->
99
+ $element1 = $('<table id="table-id">')
100
+ $element2 = $('<ul id="ul-id">')
101
+ formatted = up.log.sprintf('before %o after', $element1.add($element2))
102
+ expect(formatted).toEqual('before $(<table id="table-id">, <ul id="ul-id">) after')
103
+
104
+ describe 'with object argument', ->
105
+
106
+ it 'serializes to JSON', ->
107
+ object = { foo: 'foo-value', bar: 'bar-value' }
108
+ formatted = up.log.sprintf('before %o after', object)
109
+ expect(formatted).toEqual('before {"foo":"foo-value","bar":"bar-value"} after')
110
+
111
+ it "skips a key if a getter crashes", ->
112
+ object = {}
113
+ Object.defineProperty(object, 'foo', get: (-> throw "error"))
114
+ formatted = up.log.sprintf('before %o after', object)
115
+ expect(formatted).toEqual('before {} after')
116
+
117
+ object.bar = 'bar'
118
+ formatted = up.log.sprintf('before %o after', object)
119
+ expect(formatted).toEqual('before {"bar":"bar"} after')
@@ -1,23 +1,22 @@
1
- describe 'up.modal', ->
1
+ u = up.util
2
+ e = up.element
3
+ $ = jQuery
2
4
 
3
- u = up.util
5
+ describe 'up.modal', ->
4
6
 
5
7
  beforeEach ->
6
8
  up.modal.config.openDuration = 5
7
9
  up.modal.config.closeDuration = 5
8
10
 
9
11
  describe 'JavaScript functions', ->
10
- # Safari overlays the scrollbar tracker over the picture.
11
- # The scrollbar does not take space.
12
- assumedScrollbarWidth = if AgentDetector.isSafari() then 0 else 15
13
12
 
14
13
  describe 'up.modal.follow', ->
15
14
 
16
15
  it "loads the given link's destination in a dialog window", (done) ->
17
- $link = affix('a[href="/path/to"][up-modal=".middle"]').text('link')
16
+ $link = $fixture('a[href="/path/to"][up-modal=".middle"]').text('link')
18
17
  promise = up.modal.follow($link)
19
18
 
20
- u.nextFrame =>
19
+ u.task =>
21
20
  expect(@lastRequest().url).toMatch /\/path\/to$/
22
21
  @respondWith """
23
22
  <div class="before">new-before</div>
@@ -26,12 +25,12 @@ describe 'up.modal', ->
26
25
  """
27
26
 
28
27
  promise.then =>
29
- expect($('.up-modal')).toExist()
30
- expect($('.up-modal-dialog')).toExist()
31
- expect($('.up-modal-dialog .middle')).toExist()
28
+ expect($('.up-modal')).toBeAttached()
29
+ expect($('.up-modal-dialog')).toBeAttached()
30
+ expect($('.up-modal-dialog .middle')).toBeAttached()
32
31
  expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
33
- expect($('.up-modal-dialog .before')).not.toExist()
34
- expect($('.up-modal-dialog .after')).not.toExist()
32
+ expect($('.up-modal-dialog .before')).not.toBeAttached()
33
+ expect($('.up-modal-dialog .after')).not.toBeAttached()
35
34
  done()
36
35
 
37
36
  describe 'up.modal.extract', ->
@@ -47,12 +46,12 @@ describe 'up.modal', ->
47
46
  """
48
47
 
49
48
  promise.then =>
50
- expect($('.up-modal')).toExist()
51
- expect($('.up-modal-dialog')).toExist()
52
- expect($('.up-modal-dialog .middle')).toExist()
49
+ expect($('.up-modal')).toBeAttached()
50
+ expect($('.up-modal-dialog')).toBeAttached()
51
+ expect($('.up-modal-dialog .middle')).toBeAttached()
53
52
  expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
54
- expect($('.up-modal-dialog .before')).not.toExist()
55
- expect($('.up-modal-dialog .after')).not.toExist()
53
+ expect($('.up-modal-dialog .before')).not.toBeAttached()
54
+ expect($('.up-modal-dialog .after')).not.toBeAttached()
56
55
 
57
56
  # Can't change URLs
58
57
  expect(location.href).toEqual(oldHref)
@@ -65,7 +64,7 @@ describe 'up.modal', ->
65
64
 
66
65
  promise = up.modal.visit('/foo', target: '.middle')
67
66
 
68
- u.nextFrame =>
67
+ u.task =>
69
68
  @respondWith """
70
69
  <div class="before">new-before</div>
71
70
  <div class="middle">new-middle</div>
@@ -73,21 +72,21 @@ describe 'up.modal', ->
73
72
  """
74
73
 
75
74
  promise.then =>
76
- expect('.up-modal').toExist()
77
- expect('.up-modal-dialog').toExist()
78
- expect('.up-modal-dialog .middle').toExist()
75
+ expect('.up-modal').toBeAttached()
76
+ expect('.up-modal-dialog').toBeAttached()
77
+ expect('.up-modal-dialog .middle').toBeAttached()
79
78
  expect('.up-modal-dialog .middle').toHaveText('new-middle')
80
- expect('.up-modal-dialog .before').not.toExist()
81
- expect('.up-modal-dialog .after').not.toExist()
79
+ expect('.up-modal-dialog .before').not.toBeAttached()
80
+ expect('.up-modal-dialog .after').not.toBeAttached()
82
81
  expect(location.pathname).toMatchUrl('/foo')
83
82
  done()
84
83
 
85
84
  it "doesn't create an .up-modal frame and replaces { failTarget } if the server returns a non-200 response", (done) ->
86
- affix('.error').text('old error')
85
+ $fixture('.error').text('old error')
87
86
 
88
87
  promise = up.modal.visit('/foo', target: '.target', failTarget: '.error')
89
88
 
90
- u.nextFrame =>
89
+ u.task =>
91
90
  @respondWith
92
91
  status: 500
93
92
  responseText: """
@@ -96,7 +95,7 @@ describe 'up.modal', ->
96
95
  """
97
96
 
98
97
  promise.catch =>
99
- expect('.up-modal').not.toExist()
98
+ expect('.up-modal').not.toBeAttached()
100
99
  expect('.error').toHaveText('new error')
101
100
  done()
102
101
 
@@ -110,29 +109,42 @@ describe 'up.modal', ->
110
109
  describe 'preventing elements from jumping as scrollbars change', ->
111
110
 
112
111
  it "brings its own scrollbar, padding the body on the right", (done) ->
113
- promise = up.modal.visit('/foo', target: '.container')
112
+ $body = $(document.body)
114
113
 
115
- u.nextFrame =>
116
- @respondWith('<div class="container">text</div>')
114
+ $fixture('.spacer').css(height: '9000px')
115
+ # Safari 11 has no vertical scrollbar that takes away space from the document,
116
+ # so the entire shifting logic is skipped.
117
+ if up.viewport.rootHasVerticalScrollbar()
117
118
 
118
- promise.then ->
119
- $modal = $('.up-modal')
120
- $viewport = $modal.find('.up-modal-viewport')
121
- $body = $('body')
122
- expect($modal).toExist()
123
- expect($viewport.css('overflow-y')).toEqual('scroll')
124
- expect($body.css('overflow-y')).toEqual('hidden')
125
- expect(parseInt($body.css('padding-right'))).toBeAround(assumedScrollbarWidth, 5)
119
+ $rootOverflowElement = $(up.viewport.rootOverflowElement())
126
120
 
127
- up.modal.close().then ->
128
- expect($body.css('overflow-y')).toEqual('scroll')
129
- expect(parseInt($body.css('padding-right'))).toBe(0)
130
- done()
121
+ promise = up.modal.visit('/foo', target: '.container')
122
+
123
+ u.task =>
124
+ @respondWith('<div class="container">text</div>')
125
+
126
+ promise.then ->
127
+ $modal = $('.up-modal')
128
+ $viewport = $modal.find('.up-modal-viewport')
129
+ scrollbarWidth = up.viewport.scrollbarWidth()
130
+
131
+ expect($modal).toBeAttached()
132
+ expect($viewport.css('overflow-y')).toEqual('scroll')
133
+ expect($rootOverflowElement.css('overflow-y')).toEqual('hidden')
134
+ expect(parseInt($body.css('padding-right'))).toBeAround(scrollbarWidth, 5)
135
+
136
+ up.modal.close().then ->
137
+ expect($rootOverflowElement.css('overflow-y')).toEqual('scroll')
138
+ expect(parseInt($body.css('padding-right'))).toBe(0)
139
+ done()
140
+ else
141
+ expect(true).toBe(true)
142
+ done()
131
143
 
132
144
  it "gives the scrollbar to .up-modal instead of .up-modal-viewport while animating, so we don't see scaled scrollbars in a zoom-in animation", (done) ->
133
145
  openPromise = up.modal.extract('.container', '<div class="container">text</div>', animation: 'fade-in', duration: 100)
134
146
 
135
- u.setTimer 50, ->
147
+ u.timer 50, ->
136
148
  $modal = $('.up-modal')
137
149
  $viewport = $modal.find('.up-modal-viewport')
138
150
  expect($modal).toHaveClass('up-modal-animating')
@@ -145,18 +157,19 @@ describe 'up.modal', ->
145
157
  expect($viewport.css('overflow-y')).toEqual('scroll')
146
158
  closePromise = up.modal.close(animation: 'fade-out', duration: 400)
147
159
 
148
- u.setTimer 50, ->
160
+ u.timer 50, ->
149
161
  expect($modal).toHaveClass('up-modal-animating')
150
162
  expect($modal.css('overflow-y')).toEqual('scroll')
151
163
  expect($viewport.css('overflow-y')).toEqual('hidden')
152
164
  done()
153
165
 
154
- it 'does not add right padding to the body if the body has overflow-y: hidden', (done) ->
155
- restoreBody = u.writeTemporaryStyle($('body'), overflowY: 'hidden')
166
+ it "does not add right padding to the body if the document's overflow element has overflow-y: hidden", (done) ->
167
+ restoreBody = e.setTemporaryStyle(up.viewport.rootOverflowElement(), overflowY: 'hidden')
168
+ $fixture('.spacer').css(height: '9000px')
156
169
 
157
170
  up.modal.extract('.container', '<div class="container">text</div>').then ->
158
171
  $body = $('body')
159
- expect($('.up-modal')).toExist()
172
+ expect($('.up-modal')).toBeAttached()
160
173
  expect(parseInt($body.css('padding-right'))).toBe(0)
161
174
 
162
175
  up.modal.close().then ->
@@ -164,13 +177,13 @@ describe 'up.modal', ->
164
177
  restoreBody()
165
178
  done()
166
179
 
167
- it 'does not add right padding to the body if the body has overflow-y: auto, but does not currently have scrollbars', (done) ->
168
- restoreBody = u.writeTemporaryStyle($('body'), overflowY: 'auto')
169
- restoreReporter = u.writeTemporaryStyle($('.jasmine_html-reporter'), height: '100px', overflowY: 'hidden')
180
+ it "does not add right padding to the body if the document's overflow element has overflow-y: auto, but does not currently have scrollbars", (done) ->
181
+ restoreBody = e.setTemporaryStyle(up.viewport.rootOverflowElement(), overflowY: 'auto')
182
+ restoreReporter = e.setTemporaryStyle($('.jasmine_html-reporter')[0], height: '100px', overflowY: 'hidden')
170
183
 
171
184
  up.modal.extract('.container', '<div class="container">text</div>').then ->
172
185
  $body = $('body')
173
- expect($('.up-modal')).toExist()
186
+ expect($('.up-modal')).toBeAttached()
174
187
  expect(parseInt($body.css('padding-right'))).toBe(0)
175
188
 
176
189
  up.modal.close().then ->
@@ -180,29 +193,37 @@ describe 'up.modal', ->
180
193
  done()
181
194
 
182
195
  it 'pushes right-anchored elements away from the edge of the screen', (done) ->
196
+ $fixture('.spacer').css(height: '9000px')
197
+ # Safari 11 has no vertical scrollbar that takes away space from the document,
198
+ # so the entire shifting logic is skipped.
199
+ if up.viewport.rootHasVerticalScrollbar()
200
+ scrollbarWidth = up.viewport.scrollbarWidth()
201
+ $anchoredElement = $fixture('div[up-anchored=right]').css
202
+ position: 'absolute'
203
+ top: '0'
204
+ right: '30px'
183
205
 
184
- $anchoredElement = affix('div[up-anchored=right]').css
185
- position: 'absolute'
186
- top: '0'
187
- right: '30px'
188
-
189
- promise = up.modal.visit('/foo', target: '.container')
206
+ promise = up.modal.visit('/foo', target: '.container')
190
207
 
191
- u.nextFrame =>
192
- @respondWith('<div class="container">text</div>')
208
+ u.task =>
209
+ @respondWith('<div class="container">text</div>')
193
210
 
194
- promise.then ->
195
- expect(parseInt($anchoredElement.css('right'))).toBeAround(30 + assumedScrollbarWidth, 10)
211
+ promise.then ->
212
+ expect(parseInt($anchoredElement.css('right'))).toBeAround(30 + scrollbarWidth, 10)
196
213
 
197
- up.modal.close().then ->
198
- expect(parseInt($anchoredElement.css('right'))).toBeAround(30 , 10)
199
- done()
214
+ up.modal.close().then ->
215
+ expect(parseInt($anchoredElement.css('right'))).toBeAround(30 , 10)
216
+ done()
217
+ else
218
+ expect(true).toBe(true)
219
+ done()
200
220
 
201
221
  describe 'opening a modal while another modal is open', ->
202
222
 
203
223
  it 'does not open multiple modals or pad the body twice if the user starts loading a second modal before the first was done loading', (done) ->
204
224
  up.modal.config.closeDuration = 10
205
-
225
+ scrollbarWidth = up.viewport.scrollbarWidth()
226
+
206
227
  # Load a first modal
207
228
  up.modal.visit('/path1', target: '.container', animation: 'fade-in', duration: 50)
208
229
 
@@ -210,7 +231,7 @@ describe 'up.modal', ->
210
231
  # This will discard the first request immediately.
211
232
  up.modal.visit('/path2', target: '.container', animation: 'fade-in', duration: 50)
212
233
 
213
- u.nextFrame =>
234
+ u.task =>
214
235
  # The second modal has survived
215
236
  expect(jasmine.Ajax.requests.count()).toEqual(1)
216
237
  expect(@lastRequest().url).toMatchUrl('/path2')
@@ -218,31 +239,31 @@ describe 'up.modal', ->
218
239
  # We send the response for 2
219
240
  @respondWith('<div class="container">response2</div>')
220
241
 
221
- u.setTimer 10, =>
242
+ u.timer 10, =>
222
243
  # The second modal is now opening
223
244
  up.modal.visit('/path3', target: '.container', animation: 'fade-in', duration: 50)
224
245
 
225
246
  # Load a third modal before the second was done opening
226
- u.nextFrame =>
247
+ u.task =>
227
248
  # Since we're still opening the second modal, no request has been made.
228
249
  expect(jasmine.Ajax.requests.count()).toEqual(1)
229
250
 
230
- u.setTimer 180, =>
251
+ u.timer 180, =>
231
252
  # Now that the second modal has opened, we make the request to /path3
232
253
  expect(jasmine.Ajax.requests.count()).toEqual(2)
233
254
  expect(@lastRequest().url).toMatchUrl('/path3')
234
255
 
235
256
  @respondWith('<div class="container">response3</div>')
236
257
 
237
- u.setTimer 180, =>
258
+ u.timer 180, =>
238
259
  expect(jasmine.Ajax.requests.count()).toEqual(2)
239
260
  expect($('.up-modal').length).toBe(1)
240
261
  expect($('.up-modal-dialog').length).toBe(1)
241
262
  expect($('.container')).toHaveText('response3')
242
263
  bodyPadding = parseInt($('body').css('padding-right'))
243
- expect(bodyPadding).toBeAround(assumedScrollbarWidth, 10)
244
- if assumedScrollbarWidth > 0 # this test does not make sense on Safari
245
- expect(bodyPadding).not.toBeAround(2 * assumedScrollbarWidth, 2 * 5)
264
+ expect(bodyPadding).toBeAround(scrollbarWidth, 10)
265
+ if scrollbarWidth > 0 # this test does not make sense on old Safaris
266
+ expect(bodyPadding).not.toBeAround(2 * scrollbarWidth, 2 * 5)
246
267
  done()
247
268
 
248
269
  it 'closes the current modal and wait for its close animation to finish before starting the open animation of a second modal', asyncSpec (next) ->
@@ -319,13 +340,13 @@ describe 'up.modal', ->
319
340
  closeAnimation: 'move-to-right'
320
341
 
321
342
  animations = []
322
- spyOn(up, 'animate').and.callFake ($element, animation, options) ->
323
- if $element.is('.up-modal-viewport')
343
+ spyOn(up, 'animate').and.callFake (element, animation, options) ->
344
+ if e.matches(element, '.up-modal-viewport')
324
345
  animations.push
325
- text: u.trim($element.find('.target').text())
346
+ text: element.querySelector('.target').innerText.trim()
326
347
  animation: animation
327
348
  deferred = u.newDeferred()
328
- u.setTimer options.duration, -> deferred.resolve()
349
+ u.timer options.duration, -> deferred.resolve()
329
350
  deferred.promise()
330
351
 
331
352
  up.modal.extract('.target', '<div class="target">response1</div>')
@@ -370,7 +391,7 @@ describe 'up.modal', ->
370
391
  expect(respond).not.toThrowError()
371
392
 
372
393
  next.await =>
373
- expect($('.up-toast')).not.toExist()
394
+ expect($('.up-toast')).not.toBeAttached()
374
395
  promise = promiseState(openPromise)
375
396
  promise.then (result) => expect(result.state).toEqual('pending')
376
397
 
@@ -384,7 +405,7 @@ describe 'up.modal', ->
384
405
 
385
406
  expect(up.modal.coveredUrl()).toBeMissing()
386
407
  visitPromise = up.modal.visit('/bar', target: '.container')
387
- u.nextFrame =>
408
+ u.task =>
388
409
  @respondWith('<div class="container">text</div>')
389
410
  visitPromise.then ->
390
411
  expect(up.modal.coveredUrl()).toMatchUrl('/foo')
@@ -396,7 +417,7 @@ describe 'up.modal', ->
396
417
 
397
418
  it 'allows to register new modal variants with its own default configuration', asyncSpec (next) ->
398
419
  up.modal.flavors.variant = { maxWidth: 200 }
399
- $link = affix('a[href="/path"][up-modal=".target"][up-flavor="variant"]')
420
+ $link = $fixture('a[href="/path"][up-modal=".target"][up-flavor="variant"]')
400
421
  Trigger.click($link)
401
422
 
402
423
  next =>
@@ -405,13 +426,13 @@ describe 'up.modal', ->
405
426
  next =>
406
427
  $modal = $('.up-modal')
407
428
  $dialog = $modal.find('.up-modal-dialog')
408
- expect($modal).toBeInDOM()
429
+ expect($modal).toBeAttached()
409
430
  expect($modal.attr('up-flavor')).toEqual('variant')
410
431
  expect($dialog.attr('style')).toContain('max-width: 200px')
411
432
 
412
433
  it 'does not change the configuration of non-flavored modals', asyncSpec (next) ->
413
434
  up.modal.flavors.variant = { maxWidth: 200 }
414
- $link = affix('a[href="/path"][up-modal=".target"]')
435
+ $link = $fixture('a[href="/path"][up-modal=".target"]')
415
436
  Trigger.click($link)
416
437
 
417
438
  next =>
@@ -420,7 +441,7 @@ describe 'up.modal', ->
420
441
  next =>
421
442
  $modal = $('.up-modal')
422
443
  $dialog = $modal.find('.up-modal-dialog')
423
- expect($modal).toBeInDOM()
444
+ expect($modal).toBeAttached()
424
445
  expect($dialog.attr('style')).toBeBlank()
425
446
 
426
447
  describe 'up.modal.close', ->
@@ -428,11 +449,11 @@ describe 'up.modal', ->
428
449
  it 'closes a currently open modal', (done) ->
429
450
  up.modal.extract('.content', '<div class="content">Modal content</div>')
430
451
 
431
- u.nextFrame =>
432
- expect('.up-modal .content').toBeInDOM()
452
+ u.task =>
453
+ expect('.up-modal .content').toBeAttached()
433
454
 
434
455
  up.modal.close().then ->
435
- expect('.up-modal .content').not.toBeInDOM()
456
+ expect('.up-modal .content').not.toBeAttached()
436
457
  done()
437
458
 
438
459
  it 'does nothing if no modal is open', (done) ->
@@ -454,12 +475,12 @@ describe 'up.modal', ->
454
475
  # Some examples only want to check if follow() has been called, without
455
476
  # actually making a request.
456
477
  @stubFollow = =>
457
- @$link = affix('a[href="/path"][up-modal=".target"]')
478
+ @$link = $fixture('a[href="/path"][up-modal=".target"]')
458
479
  @followSpy = up.modal.knife.mock('followAsap').and.returnValue(Promise.resolve())
459
480
  @defaultSpy = spyOn(up.link, 'allowDefault').and.callFake((event) -> event.preventDefault())
460
481
 
461
482
  it 'opens the clicked link in a modal', asyncSpec (next) ->
462
- @$link = affix('a[href="/path"][up-modal=".target"]')
483
+ @$link = $fixture('a[href="/path"][up-modal=".target"]')
463
484
  Trigger.click(@$link)
464
485
 
465
486
  next =>
@@ -468,7 +489,7 @@ describe 'up.modal', ->
468
489
  @respondWith '<div class="target">new content</div>'
469
490
 
470
491
  next =>
471
- expect('.up-modal').toExist()
492
+ expect('.up-modal').toBeAttached()
472
493
  expect('.up-modal-content').toHaveText('new content')
473
494
 
474
495
  describe 'when modifier keys are held', ->
@@ -504,7 +525,7 @@ describe 'up.modal', ->
504
525
  it 'opens the modal on mousedown (instead of on click)', asyncSpec (next) ->
505
526
  Trigger.mousedown(@$link)
506
527
  next =>
507
- expect(@followSpy).toHaveBeenCalledWith(@$link, {})
528
+ expect(@followSpy).toHaveBeenCalledWith(@$link[0], {})
508
529
 
509
530
  it 'does nothing on mouseup', asyncSpec (next) ->
510
531
  Trigger.mouseup(@$link)
@@ -535,7 +556,7 @@ describe 'up.modal', ->
535
556
  describe 'with [up-method] modifier', ->
536
557
 
537
558
  it 'honours the given method', asyncSpec (next) ->
538
- $link = affix('a[href="/path"][up-modal=".target"][up-method="post"]')
559
+ $link = $fixture('a[href="/path"][up-modal=".target"][up-method="post"]')
539
560
  Trigger.click($link)
540
561
 
541
562
  next =>
@@ -548,7 +569,7 @@ describe 'up.modal', ->
548
569
 
549
570
  up.history.push('/original-path')
550
571
 
551
- $container = affix('.container').text('old container content')
572
+ $container = $fixture('.container').text('old container content')
552
573
  $link = $container.affix('a[href="/new-path"][up-modal=".target"]')
553
574
 
554
575
  expect(location.pathname).toEqual('/original-path')
@@ -570,13 +591,13 @@ describe 'up.modal', ->
570
591
  next =>
571
592
  expect(location.pathname).toEqual('/original-path')
572
593
  expect('.container').toHaveText('restored container content')
573
- expect('.up-modal').not.toExist()
594
+ expect('.up-modal').not.toBeAttached()
574
595
 
575
596
  it 'allows to open a modal after closing a previous modal with the escape key (bugfix)', asyncSpec (next) ->
576
597
  up.motion.config.enabled = false
577
598
 
578
- $link1 = affix('a[href="/path1"][up-modal=".target"]')
579
- $link2 = affix('a[href="/path2"][up-modal=".target"]')
599
+ $link1 = $fixture('a[href="/path1"][up-modal=".target"]')
600
+ $link2 = $fixture('a[href="/path2"][up-modal=".target"]')
580
601
  Trigger.clickSequence($link1)
581
602
 
582
603
  next =>
@@ -585,8 +606,7 @@ describe 'up.modal', ->
585
606
  next =>
586
607
  expect(up.modal.isOpen()).toBe(true)
587
608
 
588
- escapeEvent = $.Event('keydown', keyCode: 27)
589
- $('body').trigger(escapeEvent)
609
+ Trigger.escapeSequence(document.body)
590
610
 
591
611
  next =>
592
612
  expect(up.modal.isOpen()).toBe(false)
@@ -606,7 +626,7 @@ describe 'up.modal', ->
606
626
  up.motion.config.enabled = false
607
627
 
608
628
  it 'slides in a drawer that covers the full height of the screen', asyncSpec (next) ->
609
- $link = affix('a[href="/foo"][up-drawer=".target"]').text('label')
629
+ $link = $fixture('a[href="/qux"][up-drawer=".target"]').text('label')
610
630
  up.hello($link)
611
631
  Trigger.clickSequence($link)
612
632
 
@@ -616,13 +636,13 @@ describe 'up.modal', ->
616
636
  next =>
617
637
  expect(up.modal.isOpen()).toBe(true)
618
638
  expect($('.up-modal').attr('up-flavor')).toEqual('drawer')
619
- windowHeight = u.clientSize().height
639
+ windowHeight = up.viewport.rootHeight()
620
640
  modalHeight = $('.up-modal-content').outerHeight()
621
641
  expect(modalHeight).toEqual(windowHeight)
622
642
  expect($('.up-modal-content').offset()).toEqual(top: 0, left: 0)
623
643
 
624
644
  it 'puts the drawer on the right if the opening link sits in the right 50% of the screen', asyncSpec (next) ->
625
- $link = affix('a[href="/foo"][up-drawer=".target"]').text('label')
645
+ $link = $fixture('a[href="/foo"][up-drawer=".target"]').text('label')
626
646
  $link.css
627
647
  position: 'absolute'
628
648
  right: '0'
@@ -634,9 +654,9 @@ describe 'up.modal', ->
634
654
 
635
655
  next =>
636
656
  expect(up.modal.isOpen()).toBe(true)
637
- windowWidth = u.clientSize().width
657
+ windowWidth = up.viewport.rootWidth()
638
658
  modalWidth = $('.up-modal-content').outerWidth()
639
- scrollbarWidth = u.scrollbarWidth()
659
+ scrollbarWidth = up.viewport.scrollbarWidth()
640
660
  expect($('.up-modal-content').offset().left).toBeAround(windowWidth - modalWidth - scrollbarWidth, 1.0)
641
661
 
642
662
  describe '[up-close]', ->
@@ -665,7 +685,7 @@ describe 'up.modal', ->
665
685
  describe 'when no modal is open', ->
666
686
 
667
687
  it 'does nothing and allows the event chain to continue', asyncSpec (next) ->
668
- $link = affix('a[up-close]') # link is outside the modal
688
+ $link = $fixture('a[up-close]') # link is outside the modal
669
689
  up.hello($link)
670
690
  Trigger.clickSequence($link)
671
691
 
@@ -695,7 +715,7 @@ describe 'up.modal', ->
695
715
  expect(up.modal.isOpen()).toBe(false)
696
716
 
697
717
  it "does not close the modal when clicking on an element outside the modal's DOM hierarchy", asyncSpec (next) ->
698
- $container = affix('.container')
718
+ $container = $fixture('.container')
699
719
  up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
700
720
 
701
721
  next =>
@@ -712,8 +732,7 @@ describe 'up.modal', ->
712
732
  up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
713
733
 
714
734
  next =>
715
- escapeEvent = $.Event('keydown', keyCode: 27)
716
- $('body').trigger(escapeEvent)
735
+ Trigger.escapeSequence(document.body)
717
736
 
718
737
  next =>
719
738
  expect(wasClosed).toBe(true)
@@ -739,7 +758,7 @@ describe 'up.modal', ->
739
758
  up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
740
759
 
741
760
  next =>
742
- expect('.up-modal').not.toContainElement('.up-modal-close')
761
+ expect('.up-modal').not.toHaveDescendant('.up-modal-close')
743
762
 
744
763
  it 'does not close the modal on backdrop click', asyncSpec (next) ->
745
764
  up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
@@ -755,8 +774,7 @@ describe 'up.modal', ->
755
774
  up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
756
775
 
757
776
  next =>
758
- escapeEvent = $.Event('keydown', keyCode: 27)
759
- $('body').trigger(escapeEvent)
777
+ Trigger.escapeSequence(document.body)
760
778
 
761
779
  next =>
762
780
  expect(up.modal.isOpen()).toBe(true)
@@ -767,7 +785,7 @@ describe 'up.modal', ->
767
785
  up.motion.config.enabled = false
768
786
 
769
787
  it 'prefers to replace a selector within the modal', asyncSpec (next) ->
770
- $outside = affix('.foo').text('old outside')
788
+ $outside = $fixture('.foo').text('old outside')
771
789
  up.modal.visit('/path', target: '.foo')
772
790
 
773
791
  next =>
@@ -777,12 +795,12 @@ describe 'up.modal', ->
777
795
  up.extract('.foo', "<div class='foo'>new text</div>")
778
796
 
779
797
  next =>
780
- expect($outside).toBeInDOM()
798
+ expect($outside).toBeAttached()
781
799
  expect($outside).toHaveText('old outside')
782
800
  expect($('.up-modal-content')).toHaveText('new text')
783
801
 
784
802
  it 'auto-closes the modal when a replacement from inside the modal affects a selector behind the modal', asyncSpec (next) ->
785
- affix('.outside').text('old outside')
803
+ $fixture('.outside').text('old outside')
786
804
  up.modal.visit('/path', target: '.inside')
787
805
 
788
806
  next =>
@@ -793,7 +811,7 @@ describe 'up.modal', ->
793
811
 
794
812
  next =>
795
813
  expect($('.outside')).toHaveText('new outside')
796
- expect($('.up-modal')).not.toExist()
814
+ expect($('.up-modal')).not.toBeAttached()
797
815
 
798
816
  it 'does not restore the covered URL when auto-closing (since it would override the URL from the triggering update)', asyncSpec (next) ->
799
817
  up.history.config.enabled = true
@@ -801,7 +819,7 @@ describe 'up.modal', ->
801
819
  up.modal.config.openDuration = 0
802
820
  up.modal.config.closeDuration = 20
803
821
 
804
- affix('.outside').text('old outside')
822
+ $fixture('.outside').text('old outside')
805
823
  up.modal.visit('/path', target: '.inside')
806
824
 
807
825
  next =>
@@ -815,7 +833,7 @@ describe 'up.modal', ->
815
833
  expect(location.href).toMatchUrl '/new-location'
816
834
 
817
835
  it 'does not auto-close the modal when a replacement from inside the modal affects a selector inside the modal', asyncSpec (next) ->
818
- affix('.outside').text('old outside')
836
+ $fixture('.outside').text('old outside')
819
837
  up.modal.visit('/path', target: '.inside')
820
838
 
821
839
  next =>
@@ -826,10 +844,10 @@ describe 'up.modal', ->
826
844
 
827
845
  next =>
828
846
  expect($('.inside')).toHaveText('new inside')
829
- expect($('.up-modal')).toExist()
847
+ expect($('.up-modal')).toBeAttached()
830
848
 
831
849
  it 'does not auto-close the modal when a replacement from outside the modal affects a selector outside the modal', asyncSpec (next) ->
832
- affix('.outside').text('old outside')
850
+ $fixture('.outside').text('old outside')
833
851
  up.modal.visit('/path', target: '.inside')
834
852
 
835
853
  next =>
@@ -840,10 +858,10 @@ describe 'up.modal', ->
840
858
 
841
859
  next =>
842
860
  expect($('.outside')).toHaveText('new outside')
843
- expect($('.up-modal')).toExist()
861
+ expect($('.up-modal')).toBeAttached()
844
862
 
845
863
  it 'does not auto-close the modal when a replacement from outside the modal affects a selector inside the modal', asyncSpec (next) ->
846
- affix('.outside').text('old outside')
864
+ $fixture('.outside').text('old outside')
847
865
  up.modal.visit('/path', target: '.inside')
848
866
 
849
867
  next =>
@@ -854,7 +872,7 @@ describe 'up.modal', ->
854
872
 
855
873
  next =>
856
874
  expect($('.inside')).toHaveText('new inside')
857
- expect($('.up-modal')).toExist()
875
+ expect($('.up-modal')).toBeAttached()
858
876
 
859
877
  it 'does not auto-close the modal when the new fragment is within a popup', asyncSpec (next) ->
860
878
  up.modal.visit('/modal', target: '.modal-content')
@@ -869,8 +887,8 @@ describe 'up.modal', ->
869
887
  @respondWith("<div class='popup-content'></div>")
870
888
 
871
889
  next =>
872
- expect($('.up-modal')).toExist()
873
- expect($('.up-popup')).toExist()
890
+ expect($('.up-modal')).toBeAttached()
891
+ expect($('.up-popup')).toBeAttached()
874
892
 
875
893
  it 'does not close the modal when a clicked [up-target] link within the modal links to cached content (bugfix)', asyncSpec (next) ->
876
894
  up.modal.extract '.content', """
@@ -881,7 +899,7 @@ describe 'up.modal', ->
881
899
 
882
900
  next =>
883
901
  $link = $('.up-modal .content a')
884
- expect($link).toExist()
902
+ expect($link).toBeAttached()
885
903
  up.proxy.preload($link)
886
904
 
887
905
  next =>
@@ -895,5 +913,5 @@ describe 'up.modal', ->
895
913
  Trigger.clickSequence('.up-modal .content a')
896
914
 
897
915
  next =>
898
- expect($('.up-modal')).toExist()
916
+ expect($('.up-modal')).toBeAttached()
899
917
  expect($('.up-modal .content')).toHaveText('new text')