unpoly-rails 0.57.0 → 0.60.0

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.

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,7 @@
1
+ u = up.util
2
+ e = up.element
3
+ $ = jQuery
4
+
1
5
  describe 'up.popup', ->
2
6
 
3
7
  u = up.util
@@ -13,16 +17,16 @@ describe 'up.popup', ->
13
17
  popupDims = $popup.get(0).getBoundingClientRect()
14
18
  linkDims = $link.get(0).getBoundingClientRect()
15
19
  pass:
16
- Math.abs(popupDims.right - linkDims.right) < 1.0 && Math.abs(popupDims.top - linkDims.bottom) < 1.0
20
+ Math.abs(popupDims.left - linkDims.left) < 1.0 && Math.abs(popupDims.top - linkDims.bottom) < 1.0
17
21
 
18
22
  beforeEach ->
19
- @restoreBodyHeight = u.writeTemporaryStyle('body', minHeight: '3000px')
23
+ @restoreBodyHeight = e.setTemporaryStyle(document.body, minHeight: '3000px')
20
24
 
21
25
  afterEach ->
22
26
  @restoreBodyHeight()
23
27
 
24
28
  it "loads this link's destination in a popup positioned under the given link", asyncSpec (next) ->
25
- $container = affix('.container')
29
+ $container = $fixture('.container')
26
30
  $container.css
27
31
  position: 'absolute'
28
32
  left: '100px'
@@ -42,15 +46,14 @@ describe 'up.popup', ->
42
46
 
43
47
  next =>
44
48
  $popup = $('.up-popup')
45
- expect($popup).toExist()
49
+ expect($popup).toBeAttached()
46
50
  expect($popup.find('.middle')).toHaveText('new-middle')
47
- expect($popup.find('.before')).not.toExist()
48
- expect($popup.find('.after')).not.toExist()
49
- expect($popup.css('position')).toEqual('absolute')
51
+ expect($popup.find('.before')).not.toBeAttached()
52
+ expect($popup.find('.after')).not.toBeAttached()
50
53
  expect($popup).toSitBelow($link)
51
54
 
52
55
  it 'always makes a request for the given selector, and does not "improve" the selector with a fallback', asyncSpec (next) ->
53
- $container = affix('.container')
56
+ $container = $fixture('.container')
54
57
  $link = $container.affix('a[href="/path/to"][up-popup=".content"]').text('link')
55
58
  up.popup.attach($link)
56
59
  next =>
@@ -58,28 +61,8 @@ describe 'up.popup', ->
58
61
  headers = @lastRequest().requestHeaders
59
62
  expect(headers['X-Up-Target']).toEqual('.content')
60
63
 
61
- it 'gives the popup { position: "fixed" } if the given link is fixed', asyncSpec (next) ->
62
- # Let's test the harder case where the document is scrolled
63
- up.layout.scroll(document, 50)
64
- $container = affix('.container')
65
- $container.css
66
- position: 'fixed'
67
- left: '100px'
68
- top: '50px'
69
- $link = $container.affix('a[href="/path/to"][up-popup=".content"]').text('link')
70
-
71
- up.popup.attach($link)
72
-
73
- next =>
74
- @respondWith('<div class="content">popup-content</div>')
75
-
76
- next =>
77
- $popup = $('.up-popup')
78
- expect($popup.css('position')).toEqual('fixed')
79
- expect($popup).toSitBelow($link)
80
-
81
64
  it 'never resolves the open() promise and shows no error if close() was called before the response was received', asyncSpec (next) ->
82
- $span = affix('span')
65
+ $span = $fixture('span')
83
66
  openPromise = up.popup.attach($span, url: '/foo', target: '.container')
84
67
 
85
68
  next =>
@@ -90,21 +73,21 @@ describe 'up.popup', ->
90
73
  expect(respond).not.toThrowError()
91
74
 
92
75
  next.await =>
93
- expect($('.up-toast')).not.toExist()
76
+ expect($('.up-toast')).not.toBeAttached()
94
77
  promise = promiseState(openPromise)
95
78
  promise.then (result) => expect(result.state).toEqual('pending')
96
79
 
97
80
  describe 'with { html } option', ->
98
81
 
99
82
  it 'extracts the selector from the given HTML string', asyncSpec (next) ->
100
- $span = affix('span')
83
+ $span = $fixture('span')
101
84
  next.await up.popup.attach($span, target: '.container', html: "<div class='container'>container contents</div>")
102
85
  next => expect($('.up-popup')).toHaveText('container contents')
103
86
 
104
87
  describe 'opening a popup while another modal is open', ->
105
88
 
106
89
  it 'closes the current popup and wait for its close animation to finish before starting the open animation of a second popup', asyncSpec (next) ->
107
- $span = affix('span')
90
+ $span = $fixture('span')
108
91
  up.popup.config.openAnimation = 'fade-in'
109
92
  up.popup.config.openDuration = 5
110
93
  up.popup.config.closeAnimation = 'fade-out'
@@ -148,7 +131,7 @@ describe 'up.popup', ->
148
131
  up.history.replace('/foo')
149
132
  expect(up.popup.coveredUrl()).toBeMissing()
150
133
 
151
- $popupLink = affix('a[href="/bar"][up-popup=".container"][up-history="true"]')
134
+ $popupLink = $fixture('a[href="/bar"][up-popup=".container"][up-history="true"]')
152
135
  Trigger.clickSequence($popupLink)
153
136
 
154
137
  next =>
@@ -174,14 +157,14 @@ describe 'up.popup', ->
174
157
 
175
158
  beforeEach ->
176
159
  @stubAttach = =>
177
- @$link = affix('a[href="/path"][up-popup=".target"]')
160
+ @$link = $fixture('a[href="/path"][up-popup=".target"]')
178
161
  @attachSpy = up.popup.knife.mock('attachAsap').and.returnValue(Promise.resolve())
179
162
  @defaultSpy = spyOn(up.link, 'allowDefault').and.callFake((event) -> event.preventDefault())
180
163
 
181
164
  it 'opens the clicked link in a popup', asyncSpec (next) ->
182
165
  @stubAttach()
183
166
  Trigger.click(@$link)
184
- next => expect(@attachSpy).toHaveBeenCalledWith(@$link, {})
167
+ next => expect(@attachSpy).toHaveBeenCalledWith(@$link[0], {})
185
168
 
186
169
  # IE does not call JavaScript and always performs the default action on right clicks
187
170
  unless AgentDetector.isIE() || AgentDetector.isEdge()
@@ -209,8 +192,8 @@ describe 'up.popup', ->
209
192
  up.popup.config.openDuration = 0
210
193
  up.popup.config.closeDuration = 0
211
194
 
212
- $link1 = affix('a[href="/path1"][up-popup=".target"]')
213
- $link2 = affix('a[href="/path2"][up-popup=".target"]')
195
+ $link1 = $fixture('a[href="/path1"][up-popup=".target"]')
196
+ $link2 = $fixture('a[href="/path2"][up-popup=".target"]')
214
197
 
215
198
  events = []
216
199
  u.each ['up:popup:open', 'up:popup:opened', 'up:popup:close', 'up:popup:closed'], (event) ->
@@ -242,7 +225,7 @@ describe 'up.popup', ->
242
225
 
243
226
  it 'opens the modal on mousedown (instead of on click)', asyncSpec (next) ->
244
227
  Trigger.mousedown(@$link)
245
- next => expect(@attachSpy.calls.mostRecent().args[0]).toEqual(@$link)
228
+ next => expect(@attachSpy.calls.mostRecent().args[0]).toEqual(@$link[0])
246
229
 
247
230
  it 'does nothing on mouseup', asyncSpec (next) ->
248
231
  Trigger.mouseup(@$link)
@@ -273,7 +256,7 @@ describe 'up.popup', ->
273
256
  describe 'with [up-method] modifier', ->
274
257
 
275
258
  it 'honours the given method', asyncSpec (next) ->
276
- $link = affix('a[href="/path"][up-popup=".target"][up-method="post"]')
259
+ $link = $fixture('a[href="/path"][up-popup=".target"][up-method="post"]')
277
260
  Trigger.click($link)
278
261
 
279
262
  next =>
@@ -291,11 +274,11 @@ describe 'up.popup', ->
291
274
  describe 'when clicked inside a popup', ->
292
275
 
293
276
  it 'closes the open popup and halts the event chain', asyncSpec (next) ->
294
- $opener = affix('a')
277
+ $opener = $fixture('a')
295
278
  up.popup.attach($opener, html: '<div class="target">text</div>', target: '.target')
296
279
 
297
280
  next =>
298
- $popup = affix('.up-popup')
281
+ $popup = $fixture('.up-popup')
299
282
  $closer = $popup.affix('a[up-close]') # link is within the popup
300
283
  up.hello($closer)
301
284
  Trigger.clickSequence($closer)
@@ -328,7 +311,7 @@ describe 'up.popup', ->
328
311
  describe 'when no popup is open', ->
329
312
 
330
313
  it 'does nothing and allows the event chain to continue', asyncSpec (next) ->
331
- $link = affix('a[up-close]') # link is outside the popup
314
+ $link = $fixture('a[up-close]') # link is outside the popup
332
315
  up.hello($link)
333
316
  Trigger.clickSequence($link)
334
317
 
@@ -342,21 +325,21 @@ describe 'up.popup', ->
342
325
  up.motion.config.enabled = false
343
326
 
344
327
  it 'prefers to replace a selector within the popup', asyncSpec (next) ->
345
- $outside = affix('.foo').text('old outside')
346
- $link = affix('.link')
328
+ $outside = $fixture('.foo').text('old outside')
329
+ $link = $fixture('.link')
347
330
  up.popup.attach($link, target: '.foo', html: "<div class='foo'>old inside</div>")
348
331
 
349
332
  next =>
350
333
  up.extract('.foo', "<div class='foo'>new text</div>")
351
334
 
352
335
  next =>
353
- expect($outside).toBeInDOM()
336
+ expect($outside).toBeAttached()
354
337
  expect($outside).toHaveText('old outside')
355
338
  expect($('.up-popup')).toHaveText('new text')
356
339
 
357
340
  it 'auto-closes the popup when a replacement from inside the popup affects a selector behind the popup', asyncSpec (next) ->
358
- affix('.outside').text('old outside')
359
- $link = affix('.link')
341
+ $fixture('.outside').text('old outside')
342
+ $link = $fixture('.link')
360
343
  up.popup.attach($link, target: '.inside', html: "<div class='inside'>old inside</div>")
361
344
 
362
345
  next =>
@@ -364,7 +347,7 @@ describe 'up.popup', ->
364
347
 
365
348
  next =>
366
349
  expect($('.outside')).toHaveText('new outside')
367
- expect($('.up-popup')).not.toExist()
350
+ expect($('.up-popup')).not.toBeAttached()
368
351
 
369
352
  it 'does not restore the covered URL when auto-closing (since it would override the URL from the triggering update)', asyncSpec (next) ->
370
353
  up.history.config.enabled = true
@@ -373,8 +356,8 @@ describe 'up.popup', ->
373
356
  up.popup.config.closeDuration = 20
374
357
  up.popup.config.history = true
375
358
 
376
- affix('.outside').text('old outside')
377
- $link = affix('.link')
359
+ $fixture('.outside').text('old outside')
360
+ $link = $fixture('.link')
378
361
  up.popup.attach($link, url: '/path', target: '.inside')
379
362
 
380
363
  next =>
@@ -388,8 +371,8 @@ describe 'up.popup', ->
388
371
  expect(location.href).toMatchUrl '/new-location'
389
372
 
390
373
  it 'does not auto-close the popup when a replacement from inside the popup affects a selector inside the popup', asyncSpec (next) ->
391
- affix('.outside').text('old outside')
392
- $link = affix('.link')
374
+ $fixture('.outside').text('old outside')
375
+ $link = $fixture('.link')
393
376
  up.popup.attach($link, html: "<div class='inside'>old inside</div>", target: '.inside')
394
377
 
395
378
  next =>
@@ -397,11 +380,11 @@ describe 'up.popup', ->
397
380
 
398
381
  next =>
399
382
  expect($('.inside')).toHaveText('new inside')
400
- expect($('.up-popup')).toExist()
383
+ expect($('.up-popup')).toBeAttached()
401
384
 
402
385
  it 'does not auto-close the popup when a replacement from outside the popup affects a selector outside the popup', asyncSpec (next) ->
403
- affix('.outside').text('old outside')
404
- $link = affix('.link')
386
+ $fixture('.outside').text('old outside')
387
+ $link = $fixture('.link')
405
388
  up.popup.attach($link, target: '.inside', html: "<div class='inside'>old inside</div>")
406
389
 
407
390
  next =>
@@ -409,11 +392,11 @@ describe 'up.popup', ->
409
392
 
410
393
  next =>
411
394
  expect($('.outside')).toHaveText('new outside')
412
- expect($('.up-popup')).toExist()
395
+ expect($('.up-popup')).toBeAttached()
413
396
 
414
397
  it 'does not auto-close the popup when a replacement from outside the popup affects a selector inside the popup', asyncSpec (next) ->
415
- affix('.outside').text('old outside')
416
- $link = affix('.link')
398
+ $fixture('.outside').text('old outside')
399
+ $link = $fixture('.link')
417
400
  up.popup.attach($link, target: '.inside', html: "<div class='inside'>old inside</div>")
418
401
 
419
402
  next =>
@@ -421,7 +404,7 @@ describe 'up.popup', ->
421
404
 
422
405
  next =>
423
406
  expect($('.inside')).toHaveText('new inside')
424
- expect($('.up-popup')).toExist()
407
+ expect($('.up-popup')).toBeAttached()
425
408
 
426
409
  describe 'when clicking on the body', ->
427
410
 
@@ -429,8 +412,8 @@ describe 'up.popup', ->
429
412
  up.motion.config.enabled = false
430
413
 
431
414
  it 'closes the popup', asyncSpec (next) ->
432
- affix('.outside').text('old outside')
433
- $link = affix('.link')
415
+ $fixture('.outside').text('old outside')
416
+ $link = $fixture('.link')
434
417
  up.popup.attach($link, target: '.inside', html: "<div class='inside'>inside</div>")
435
418
 
436
419
  next =>
@@ -441,9 +424,9 @@ describe 'up.popup', ->
441
424
  expect(up.popup.isOpen()).toBe(false)
442
425
 
443
426
  it 'closes the popup when a an [up-instant] link removes its parent (and thus a click event never bubbles up to the document)', asyncSpec (next) ->
444
- $parent = affix('.parent')
427
+ $parent = $fixture('.parent')
445
428
  $parentReplacingLink = $parent.affix('a[href="/foo"][up-target=".parent"][up-instant]')
446
- $popupOpener = affix('.link')
429
+ $popupOpener = $fixture('.link')
447
430
  up.popup.attach($popupOpener, target: '.inside', html: "<div class='inside'>inside</div>")
448
431
 
449
432
  next =>
@@ -454,9 +437,9 @@ describe 'up.popup', ->
454
437
  expect(up.popup.isOpen()).toBe(false)
455
438
 
456
439
  it 'closes the popup when the user clicks on an [up-target] link outside the popup', asyncSpec (next) ->
457
- $target = affix('.target')
458
- $outsideLink = affix('a[href="/foo"][up-target=".target"]')
459
- $popupOpener = affix('.link')
440
+ $target = $fixture('.target')
441
+ $outsideLink = $fixture('a[href="/foo"][up-target=".target"]')
442
+ $popupOpener = $fixture('.link')
460
443
  up.popup.attach($popupOpener, target: '.inside', html: "<div class='inside'>inside</div>")
461
444
 
462
445
  next =>
@@ -467,9 +450,9 @@ describe 'up.popup', ->
467
450
  expect(up.popup.isOpen()).toBe(false)
468
451
 
469
452
  it 'closes the popup when the user clicks on an [up-instant] link outside the popup', asyncSpec (next) ->
470
- $target = affix('.target')
471
- $outsideLink = affix('a[href="/foo"][up-target=".target"][up-instant]')
472
- $popupOpener = affix('.link')
453
+ $target = $fixture('.target')
454
+ $outsideLink = $fixture('a[href="/foo"][up-target=".target"][up-instant]')
455
+ $popupOpener = $fixture('.link')
473
456
  up.popup.attach($popupOpener, target: '.inside', html: "<div class='inside'>inside</div>")
474
457
 
475
458
  next =>
@@ -480,8 +463,8 @@ describe 'up.popup', ->
480
463
  expect(up.popup.isOpen()).toBe(false)
481
464
 
482
465
  it 'does not close the popup if #preventDefault() is called on up:popup:close event', asyncSpec (next) ->
483
- affix('.outside').text('old outside')
484
- $link = affix('.link')
466
+ $fixture('.outside').text('old outside')
467
+ $link = $fixture('.link')
485
468
  up.popup.attach($link, target: '.inside', html: "<div class='inside'>inside</div>")
486
469
 
487
470
  up.on 'up:popup:close', (e) -> e.preventDefault()
@@ -498,9 +481,9 @@ describe 'up.popup', ->
498
481
  expect(window).not.toHaveUnhandledRejections()
499
482
 
500
483
  it 'does not close the popup if a link outside the popup is followed with the up.follow function (bugfix)', asyncSpec (next) ->
501
- $target = affix('.target')
502
- $outsideLink = affix('a[href="/foo"][up-target=".target"]')
503
- $popupOpener = affix('.link')
484
+ $target = $fixture('.target')
485
+ $outsideLink = $fixture('a[href="/foo"][up-target=".target"]')
486
+ $popupOpener = $fixture('.link')
504
487
  up.popup.attach($popupOpener, target: '.inside', html: "<div class='inside'>inside</div>")
505
488
 
506
489
  next =>
@@ -511,9 +494,9 @@ describe 'up.popup', ->
511
494
  expect(up.popup.isOpen()).toBe(true)
512
495
 
513
496
  it 'does not close the popup if a form outside the popup is followed with the up.submit function (bugfix)', asyncSpec (next) ->
514
- $target = affix('.target')
515
- $outsideForm = affix('form[action="/foo"][up-target=".target"]')
516
- $popupOpener = affix('.link')
497
+ $target = $fixture('.target')
498
+ $outsideForm = $fixture('form[action="/foo"][up-target=".target"]')
499
+ $popupOpener = $fixture('.link')
517
500
  up.popup.attach($popupOpener, target: '.inside', html: "<div class='inside'>inside</div>")
518
501
 
519
502
  next =>
@@ -1,4 +1,5 @@
1
1
  u = up.util
2
+ $ = jQuery
2
3
 
3
4
  describe 'up.protocol', ->
4
5
 
@@ -1,6 +1,7 @@
1
- describe 'up.proxy', ->
1
+ u = up.util
2
+ $ = jQuery
2
3
 
3
- u = up.util
4
+ describe 'up.proxy', ->
4
5
 
5
6
  describe 'JavaScript functions', ->
6
7
 
@@ -45,7 +46,7 @@ describe 'up.proxy', ->
45
46
  target: '.target'
46
47
  )
47
48
 
48
- u.nextFrame =>
49
+ u.task =>
49
50
  @respondWith(
50
51
  status: 201,
51
52
  responseText: 'response-text'
@@ -53,7 +54,7 @@ describe 'up.proxy', ->
53
54
 
54
55
  promise.then (response) ->
55
56
  expect(response.request.url).toMatchUrl('/url')
56
- expect(response.request.params).toEqual(key: 'value')
57
+ expect(response.request.params).toEqual(new up.Params(key: 'value'))
57
58
  expect(response.request.method).toEqual('POST')
58
59
  expect(response.request.target).toEqual('.target')
59
60
  expect(response.request.hash).toBeBlank()
@@ -69,7 +70,7 @@ describe 'up.proxy', ->
69
70
  it 'resolves to a Response that contains the response headers', (done) ->
70
71
  promise = up.request(url: '/url')
71
72
 
72
- u.nextFrame =>
73
+ u.task =>
73
74
  @respondWith
74
75
  responseHeaders: { 'foo': 'bar', 'baz': 'bam' }
75
76
  responseText: 'hello'
@@ -85,7 +86,7 @@ describe 'up.proxy', ->
85
86
  it "preserves the URL hash in a separate { hash } property, since although it isn't sent to server, code might need it to process the response", (done) ->
86
87
  promise = up.request('/url#hash')
87
88
 
88
- u.nextFrame =>
89
+ u.task =>
89
90
  request = @lastRequest()
90
91
  expect(request.url).toMatchUrl('/url')
91
92
 
@@ -107,7 +108,7 @@ describe 'up.proxy', ->
107
108
  target: '.target'
108
109
  )
109
110
 
110
- u.nextFrame =>
111
+ u.task =>
111
112
  @respondWith(
112
113
  responseHeaders:
113
114
  'X-Up-Location': '/redirect'
@@ -126,7 +127,7 @@ describe 'up.proxy', ->
126
127
  it 'sets the { url } property on the response object', (done) ->
127
128
  promise = up.request('/request-url#request-hash')
128
129
 
129
- u.nextFrame =>
130
+ u.task =>
130
131
  @respondWith
131
132
  responseHeaders:
132
133
  'X-Up-Location': '/response-url'
@@ -189,23 +190,25 @@ describe 'up.proxy', ->
189
190
  # See that an additional request was made
190
191
  expect(jasmine.Ajax.requests.count()).toEqual(2)
191
192
 
192
- it "does not explode if the original request's { params } is a FormData object", asyncSpec (next) ->
193
- up.request('/foo', method: 'post', params: new FormData()) # POST requests are not cached
193
+ describeCapability 'canInspectFormData', ->
194
194
 
195
- next =>
196
- expect(jasmine.Ajax.requests.count()).toEqual(1)
197
- @respondWith
198
- responseHeaders:
199
- 'X-Up-Location': '/bar'
200
- 'X-Up-Method': 'GET'
195
+ it "does not explode if the original request's { params } is a FormData object", asyncSpec (next) ->
196
+ up.request('/foo', method: 'post', params: new FormData()) # POST requests are not cached
201
197
 
202
- next =>
203
- @secondAjaxPromise = up.request('/bar')
198
+ next =>
199
+ expect(jasmine.Ajax.requests.count()).toEqual(1)
200
+ @respondWith
201
+ responseHeaders:
202
+ 'X-Up-Location': '/bar'
203
+ 'X-Up-Method': 'GET'
204
+
205
+ next =>
206
+ @secondAjaxPromise = up.request('/bar')
204
207
 
205
- next.await =>
206
- promiseState(@secondAjaxPromise).then (result) ->
207
- # See that the promise was not rejected due to an internal error.
208
- expect(result.state).toEqual('pending')
208
+ next.await =>
209
+ promiseState(@secondAjaxPromise).then (result) ->
210
+ # See that the promise was not rejected due to an internal error.
211
+ expect(result.state).toEqual('pending')
209
212
 
210
213
 
211
214
  describe 'when the XHR object has a { responseURL } property', ->
@@ -213,7 +216,7 @@ describe 'up.proxy', ->
213
216
  it 'sets the { url } property on the response object', (done) ->
214
217
  promise = up.request('/request-url#request-hash')
215
218
 
216
- u.nextFrame =>
219
+ u.task =>
217
220
  @respondWith
218
221
  responseURL: '/response-url'
219
222
 
@@ -325,7 +328,7 @@ describe 'up.proxy', ->
325
328
  givenParams = { 'foo-key': 'foo-value', 'bar-key': 'bar-value' }
326
329
  promise = up.request(url: '/path', method: 'get', params: givenParams)
327
330
 
328
- u.nextFrame =>
331
+ u.task =>
329
332
  expect(@lastRequest().url).toMatchUrl('/path?foo-key=foo-value&bar-key=bar-value')
330
333
  expect(@lastRequest().data()).toBeBlank()
331
334
 
@@ -333,7 +336,7 @@ describe 'up.proxy', ->
333
336
 
334
337
  promise.then (response) ->
335
338
  # See that the response object has been updated by moving the data options
336
- # to the URL. This is important for up.dom code that works on response.request.
339
+ # to the URL. This is important for up.fragment code that works on response.request.
337
340
  expect(response.request.url).toMatchUrl('/path?foo-key=foo-value&bar-key=bar-value')
338
341
  expect(response.request.params).toBeBlank()
339
342
  done()
@@ -554,7 +557,7 @@ describe 'up.proxy', ->
554
557
 
555
558
  promise = up.request('/bar')
556
559
 
557
- u.nextFrame ->
560
+ u.task ->
558
561
  expect(listener).toHaveBeenCalled()
559
562
  expect(jasmine.Ajax.requests.count()).toEqual(0)
560
563
 
@@ -576,7 +579,7 @@ describe 'up.proxy', ->
576
579
  promise1 = up.request('/path1')
577
580
  promise2 = up.request('/path2')
578
581
 
579
- u.nextFrame =>
582
+ u.task =>
580
583
  expect(listener.calls.count()).toBe(2)
581
584
  expect(jasmine.Ajax.requests.count()).toEqual(1)
582
585
  expect(@lastRequest().url).toMatchUrl('/path2')
@@ -590,7 +593,7 @@ describe 'up.proxy', ->
590
593
 
591
594
  up.request('/path1')
592
595
 
593
- u.nextFrame =>
596
+ u.task =>
594
597
  expect(@lastRequest().requestHeaders['X-From-Listener']).toEqual('foo')
595
598
  done()
596
599
 
@@ -757,7 +760,7 @@ describe 'up.proxy', ->
757
760
  it 'fulfills to the response text in order to match the $.ajax() API as good as possible', (done) ->
758
761
  promise = up.ajax('/url')
759
762
 
760
- u.setTimer 100, =>
763
+ u.timer 100, =>
761
764
  @respondWith('response-text')
762
765
 
763
766
  promise.then (text) ->
@@ -773,8 +776,8 @@ describe 'up.proxy', ->
773
776
  @requestTarget = => @lastRequest().requestHeaders['X-Up-Target']
774
777
 
775
778
  it "loads and caches the given link's destination", asyncSpec (next) ->
776
- affix('.target')
777
- $link = affix('a[href="/path"][up-target=".target"]')
779
+ $fixture('.target')
780
+ $link = $fixture('a[href="/path"][up-target=".target"]')
778
781
 
779
782
  up.proxy.preload($link)
780
783
 
@@ -783,8 +786,8 @@ describe 'up.proxy', ->
783
786
  expect(u.isPromise(cachedPromise)).toBe(true)
784
787
 
785
788
  it "does not load a link whose method has side-effects", (done) ->
786
- affix('.target')
787
- $link = affix('a[href="/path"][up-target=".target"][data-method="post"]')
789
+ $fixture('.target')
790
+ $link = $fixture('a[href="/path"][up-target=".target"][data-method="post"]')
788
791
  preloadPromise = up.proxy.preload($link)
789
792
 
790
793
  promiseState(preloadPromise).then (result) ->
@@ -793,8 +796,8 @@ describe 'up.proxy', ->
793
796
  done()
794
797
 
795
798
  it 'accepts options', asyncSpec (next) ->
796
- affix('.target')
797
- $link = affix('a[href="/path"][up-target=".target"]')
799
+ $fixture('.target')
800
+ $link = $fixture('a[href="/path"][up-target=".target"]')
798
801
  up.proxy.preload($link, url: '/options-path')
799
802
 
800
803
  next =>
@@ -804,13 +807,13 @@ describe 'up.proxy', ->
804
807
  describe 'for an [up-target] link', ->
805
808
 
806
809
  it 'includes the [up-target] selector as an X-Up-Target header if the targeted element is currently on the page', asyncSpec (next) ->
807
- affix('.target')
808
- $link = affix('a[href="/path"][up-target=".target"]')
810
+ $fixture('.target')
811
+ $link = $fixture('a[href="/path"][up-target=".target"]')
809
812
  up.proxy.preload($link)
810
813
  next => expect(@requestTarget()).toEqual('.target')
811
814
 
812
815
  it 'replaces the [up-target] selector as with a fallback and uses that as an X-Up-Target header if the targeted element is not currently on the page', asyncSpec (next) ->
813
- $link = affix('a[href="/path"][up-target=".target"]')
816
+ $link = $fixture('a[href="/path"][up-target=".target"]')
814
817
  up.proxy.preload($link)
815
818
  # The default fallback would usually be `body`, but in Jasmine specs we change
816
819
  # it to protect the test runner during failures.
@@ -819,7 +822,7 @@ describe 'up.proxy', ->
819
822
  it 'calls up.request() with a { preload: true } option so it bypasses the concurrency limit', asyncSpec (next) ->
820
823
  requestSpy = spyOn(up, 'request')
821
824
 
822
- $link = affix('a[href="/path"][up-target=".target"]')
825
+ $link = $fixture('a[href="/path"][up-target=".target"]')
823
826
  up.proxy.preload($link)
824
827
 
825
828
  next =>
@@ -831,18 +834,18 @@ describe 'up.proxy', ->
831
834
  up.motion.config.enabled = false
832
835
 
833
836
  it 'includes the [up-modal] selector as an X-Up-Target header and does not replace it with a fallback, since the modal frame always exists', asyncSpec (next) ->
834
- $link = affix('a[href="/path"][up-modal=".target"]')
837
+ $link = $fixture('a[href="/path"][up-modal=".target"]')
835
838
  up.proxy.preload($link)
836
839
  next => expect(@requestTarget()).toEqual('.target')
837
840
 
838
841
  it 'does not create a modal frame', asyncSpec (next) ->
839
- $link = affix('a[href="/path"][up-modal=".target"]')
842
+ $link = $fixture('a[href="/path"][up-modal=".target"]')
840
843
  up.proxy.preload($link)
841
844
  next =>
842
- expect('.up-modal').not.toExist()
845
+ expect('.up-modal').not.toBeAttached()
843
846
 
844
847
  it 'does not emit an up:modal:open event', asyncSpec (next) ->
845
- $link = affix('a[href="/path"][up-modal=".target"]')
848
+ $link = $fixture('a[href="/path"][up-modal=".target"]')
846
849
  openListener = jasmine.createSpy('listener')
847
850
  up.on('up:modal:open', openListener)
848
851
  up.proxy.preload($link)
@@ -850,43 +853,43 @@ describe 'up.proxy', ->
850
853
  expect(openListener).not.toHaveBeenCalled()
851
854
 
852
855
  it 'does not close a currently open modal', asyncSpec (next) ->
853
- $link = affix('a[href="/path"][up-modal=".target"]')
856
+ $link = $fixture('a[href="/path"][up-modal=".target"]')
854
857
  closeListener = jasmine.createSpy('listener')
855
858
  up.on('up:modal:close', closeListener)
856
859
 
857
860
  up.modal.extract('.content', '<div class="content">Modal content</div>')
858
861
 
859
862
  next =>
860
- expect('.up-modal .content').toBeInDOM()
863
+ expect('.up-modal .content').toBeAttached()
861
864
 
862
865
  next =>
863
866
  up.proxy.preload($link)
864
867
 
865
868
  next =>
866
- expect('.up-modal .content').toBeInDOM()
869
+ expect('.up-modal .content').toBeAttached()
867
870
  expect(closeListener).not.toHaveBeenCalled()
868
871
 
869
872
  next =>
870
873
  up.modal.close()
871
874
 
872
875
  next =>
873
- expect('.up-modal .content').not.toBeInDOM()
876
+ expect('.up-modal .content').not.toBeAttached()
874
877
  expect(closeListener).toHaveBeenCalled()
875
878
 
876
879
  it 'does not prevent the opening of other modals while the request is still pending', asyncSpec (next) ->
877
- $link = affix('a[href="/path"][up-modal=".target"]')
880
+ $link = $fixture('a[href="/path"][up-modal=".target"]')
878
881
  up.proxy.preload($link)
879
882
 
880
883
  next =>
881
884
  up.modal.extract('.content', '<div class="content">Modal content</div>')
882
885
 
883
886
  next =>
884
- expect('.up-modal .content').toBeInDOM()
887
+ expect('.up-modal .content').toBeAttached()
885
888
 
886
889
  it 'calls up.request() with a { preload: true } option so it bypasses the concurrency limit', asyncSpec (next) ->
887
890
  requestSpy = spyOn(up, 'request')
888
891
 
889
- $link = affix('a[href="/path"][up-modal=".target"]')
892
+ $link = $fixture('a[href="/path"][up-modal=".target"]')
890
893
  up.proxy.preload($link)
891
894
 
892
895
  next =>
@@ -898,19 +901,19 @@ describe 'up.proxy', ->
898
901
  up.motion.config.enabled = false
899
902
 
900
903
  it 'includes the [up-popup] selector as an X-Up-Target header and does not replace it with a fallback, since the popup frame always exists', asyncSpec (next) ->
901
- $link = affix('a[href="/path"][up-popup=".target"]')
904
+ $link = $fixture('a[href="/path"][up-popup=".target"]')
902
905
  up.proxy.preload($link)
903
906
  next => expect(@requestTarget()).toEqual('.target')
904
907
 
905
908
 
906
909
  it 'does not create a popup frame', asyncSpec (next) ->
907
- $link = affix('a[href="/path"][up-popup=".target"]')
910
+ $link = $fixture('a[href="/path"][up-popup=".target"]')
908
911
  up.proxy.preload($link)
909
912
  next =>
910
- expect('.up-popup').not.toExist()
913
+ expect('.up-popup').not.toBeAttached()
911
914
 
912
915
  it 'does not emit an up:popup:open event', asyncSpec (next) ->
913
- $link = affix('a[href="/path"][up-popup=".target"]')
916
+ $link = $fixture('a[href="/path"][up-popup=".target"]')
914
917
  openListener = jasmine.createSpy('listener')
915
918
  up.on('up:popup:open', openListener)
916
919
  up.proxy.preload($link)
@@ -918,45 +921,45 @@ describe 'up.proxy', ->
918
921
  expect(openListener).not.toHaveBeenCalled()
919
922
 
920
923
  it 'does not close a currently open popup', asyncSpec (next) ->
921
- $link = affix('a[href="/path"][up-popup=".target"]')
924
+ $link = $fixture('a[href="/path"][up-popup=".target"]')
922
925
  closeListener = jasmine.createSpy('listener')
923
926
  up.on('up:popup:close', closeListener)
924
927
 
925
- $existingAnchor = affix('.existing-anchor')
928
+ $existingAnchor = $fixture('.existing-anchor')
926
929
  up.popup.attach($existingAnchor, target: '.content', html: '<div class="content">popup content</div>')
927
930
 
928
931
  next =>
929
- expect('.up-popup .content').toBeInDOM()
932
+ expect('.up-popup .content').toBeAttached()
930
933
 
931
934
  next =>
932
935
  up.proxy.preload($link)
933
936
 
934
937
  next =>
935
- expect('.up-popup .content').toBeInDOM()
938
+ expect('.up-popup .content').toBeAttached()
936
939
  expect(closeListener).not.toHaveBeenCalled()
937
940
 
938
941
  next =>
939
942
  up.popup.close()
940
943
 
941
944
  next =>
942
- expect('.up-popup .content').not.toBeInDOM()
945
+ expect('.up-popup .content').not.toBeAttached()
943
946
  expect(closeListener).toHaveBeenCalled()
944
947
 
945
948
  it 'does not prevent the opening of other popups while the request is still pending', asyncSpec (next) ->
946
- $link = affix('a[href="/path"][up-popup=".target"]')
949
+ $link = $fixture('a[href="/path"][up-popup=".target"]')
947
950
  up.proxy.preload($link)
948
951
 
949
952
  next =>
950
- $anchor = affix('.existing-anchor')
953
+ $anchor = $fixture('.existing-anchor')
951
954
  up.popup.attach($anchor, target: '.content', html: '<div class="content">popup content</div>')
952
955
 
953
956
  next =>
954
- expect('.up-popup .content').toBeInDOM()
957
+ expect('.up-popup .content').toBeAttached()
955
958
 
956
959
  it 'calls up.request() with a { preload: true } option so it bypasses the concurrency limit', asyncSpec (next) ->
957
960
  requestSpy = spyOn(up, 'request')
958
961
 
959
- $link = affix('a[href="/path"][up-popup=".target"]')
962
+ $link = $fixture('a[href="/path"][up-popup=".target"]')
960
963
  up.proxy.preload($link)
961
964
 
962
965
  next =>
@@ -965,8 +968,8 @@ describe 'up.proxy', ->
965
968
  describeFallback 'canPushState', ->
966
969
 
967
970
  it "does nothing", asyncSpec (next) ->
968
- affix('.target')
969
- $link = affix('a[href="/path"][up-target=".target"]')
971
+ $fixture('.target')
972
+ $link = $fixture('a[href="/path"][up-target=".target"]')
970
973
  up.proxy.preload($link)
971
974
  next =>
972
975
  expect(jasmine.Ajax.requests.count()).toBe(0)
@@ -982,9 +985,11 @@ describe 'up.proxy', ->
982
985
  promise = up.proxy.get(url: '/foo', params: { key: 'value' })
983
986
  expect(promise).toBeUndefined()
984
987
 
985
- it "returns undefined if the given request's { params } is a FormData object", ->
986
- promise = up.proxy.get(url: '/foo', params: new FormData())
987
- expect(promise).toBeUndefined()
988
+ describeCapability 'canInspectFormData', ->
989
+
990
+ it "returns undefined if the given request's { params } is a FormData object", ->
991
+ promise = up.proxy.get(url: '/foo', params: new FormData())
992
+ expect(promise).toBeUndefined()
988
993
 
989
994
  describe 'up.proxy.set', ->
990
995
 
@@ -1000,9 +1005,11 @@ describe 'up.proxy', ->
1000
1005
 
1001
1006
  it 'does nothing if the given request is not cached'
1002
1007
 
1003
- it 'does not crash when passed a request with FormData (bugfix)', ->
1004
- removal = -> up.proxy.remove(url: '/path', params: new FormData())
1005
- expect(removal).not.toThrowError()
1008
+ describeCapability 'canInspectFormData', ->
1009
+
1010
+ it 'does not crash when passed a request with FormData (bugfix)', ->
1011
+ removal = -> up.proxy.remove(url: '/path', params: new FormData())
1012
+ expect(removal).not.toThrowError()
1006
1013
 
1007
1014
  describe 'up.proxy.clear', ->
1008
1015
 
@@ -1015,9 +1022,9 @@ describe 'up.proxy', ->
1015
1022
  it 'preloads the link destination when hovering, after a delay', asyncSpec (next) ->
1016
1023
  up.proxy.config.preloadDelay = 100
1017
1024
 
1018
- affix('.target').text('old text')
1025
+ $fixture('.target').text('old text')
1019
1026
 
1020
- $link = affix('a[href="/foo"][up-target=".target"][up-preload]')
1027
+ $link = $fixture('a[href="/foo"][up-target=".target"][up-preload]')
1021
1028
  up.hello($link)
1022
1029
 
1023
1030
  Trigger.hoverSequence($link)
@@ -1054,9 +1061,9 @@ describe 'up.proxy', ->
1054
1061
  it 'does not send a request if the user stops hovering before the delay is over', asyncSpec (next) ->
1055
1062
  up.proxy.config.preloadDelay = 100
1056
1063
 
1057
- affix('.target').text('old text')
1064
+ $fixture('.target').text('old text')
1058
1065
 
1059
- $link = affix('a[href="/foo"][up-target=".target"][up-preload]')
1066
+ $link = $fixture('a[href="/foo"][up-target=".target"][up-preload]')
1060
1067
  up.hello($link)
1061
1068
 
1062
1069
  Trigger.hoverSequence($link)
@@ -1073,9 +1080,9 @@ describe 'up.proxy', ->
1073
1080
  it 'does not cache a failed response', asyncSpec (next) ->
1074
1081
  up.proxy.config.preloadDelay = 0
1075
1082
 
1076
- affix('.target').text('old text')
1083
+ $fixture('.target').text('old text')
1077
1084
 
1078
- $link = affix('a[href="/foo"][up-target=".target"][up-preload]')
1085
+ $link = $fixture('a[href="/foo"][up-target=".target"][up-preload]')
1079
1086
  up.hello($link)
1080
1087
 
1081
1088
  Trigger.hoverSequence($link)
@@ -1109,7 +1116,7 @@ describe 'up.proxy', ->
1109
1116
  up.proxy.config.cacheExpiry = 100
1110
1117
  up.proxy.config.preloadDelay = 0
1111
1118
 
1112
- $element = affix('a[href="/foo"][up-preload]')
1119
+ $element = $fixture('a[href="/foo"][up-preload]')
1113
1120
  up.hello($element)
1114
1121
 
1115
1122
  Trigger.hoverSequence($element)